Kun*_*ade 1 elasticsearch elasticsearch-mapping
我正在尝试使用以下代码更改映射:
PUT /in_test/_mapping/keyword
{
"properties" : {
"term" : {
"type" : "text",
"index" : "not_analyzed"
}
}
}
Run Code Online (Sandbox Code Playgroud)
但它给出了一个错误:
{
"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
}
Run Code Online (Sandbox Code Playgroud)
我还尝试通过以下方式重新创建索引:
PUT /in_test
{
"mappings" : {
"keyword" : {
"properties" : {
"term" : {
"type" : "text",
"index" : "not_analyzed"
}
}
}
}
}
Run Code Online (Sandbox Code Playgroud)
但我得到了:
{
"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
}
Run Code Online (Sandbox Code Playgroud)
我还尝试将 _type 更改为关键字,但它仍然不起作用。基本上,我想搜索字符串的精确匹配,为此我指的是:
该文档页面来自 Elasticsearch 版本 2.X(请参阅页面顶部),对于现代版本的 Elasticsearch 来说不再正确。
您收到的错误是因为“index”现在只接受true或false,并且指的是该属性是否完全被索引 - 由于您正在按此属性进行搜索,因此您希望它是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"
}
}
}
}
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
4588 次 |
| 最近记录: |