gpt4 book ai didi

elasticsearch - 更改 Elasticsearch 映射

转载 作者:行者123 更新时间:2023-12-03 00:34:52 25 4
gpt4 key购买 nike

我正在尝试使用以下代码更改映射:

PUT /in_test/_mapping/keyword
{
"properties" : {
"term" : {
"type" : "text",
"index" : "not_analyzed"
}
}
}

但是它给出了一个错误:
{
"error": {
"root_cause": [
{
"type": "remote_transport_exception",
"reason": "[tiebreaker-0000000000][172.17.0.24:19555][indices:admin/mapping/put]"
}
],
"type": "illegal_argument_exception",
"reason": "Could not convert [term.index] to boolean",
"caused_by": {
"type": "illegal_argument_exception",
"reason": "Failed to parse value [not_analyzed] as only [true] or [false] are allowed."
}
},
"status": 400
}

我也试图重新创建索引
通过:
PUT /in_test
{
"mappings" : {
"keyword" : {
"properties" : {
"term" : {
"type" : "text",
"index" : "not_analyzed"
}
}
}
}
}

但是我得到了:
{
"error": {
"root_cause": [
{
"type": "mapper_parsing_exception",
"reason": "Failed to parse mapping [keyword]: Could not convert [term.index] to boolean"
}
],
"type": "mapper_parsing_exception",
"reason": "Failed to parse mapping [keyword]: Could not convert [term.index] to boolean",
"caused_by": {
"type": "illegal_argument_exception",
"reason": "Could not convert [term.index] to boolean",
"caused_by": {
"type": "illegal_argument_exception",
"reason": "Failed to parse value [not_analyzed] as only [true] or [false] are allowed."
}
}
},
"status": 400
}

我也尝试将_type更改为关键字,但仍然无法正常工作。
基本上,我想搜索字符串的完全匹配,为此,我指的是:

https://www.elastic.co/guide/en/elasticsearch/guide/current/_finding_exact_values.html#_term_query_with_text

最佳答案

该文档页面来自Elasticsearch 2.X版(请参阅页面顶部),并且不再适用于现代版本的Elasticsearch。

您得到的错误是因为“index”现在仅接受truefalse,并指示是否对属性进行了索引-由于您要通过该属性进行搜索,因此您希望它成为true(默认值) 。

相反,尝试将类型设置为“关键字”,并且不会被标记化。 https://www.elastic.co/guide/en/elasticsearch/reference/current/analysis-keyword-analyzer.html#_definition_5

PUT /in_test
{
"mappings" : {
"keyword" : {
"properties" : {
"term" : {
"type" : "keyword"
}
}
}
}
}

关于elasticsearch - 更改 Elasticsearch 映射,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49567552/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com