我正在尝试为一个字段创建映射,该映射仅需要用于完全匹配和排序。我不想将主要数据类型设置为文本,因为我只需要完全匹配即可。
{
"index_patterns": "*",
"mappings": {
"doc": {
"_source": {
"enabled": true
},
"properties": {
"my_field": {
"type": "keyword",
"index": true,
"fielddata": true
}
}
}
}
}
但是我遇到以下错误:
{
"error": {
"root_cause": [
{
"type": "mapper_parsing_exception",
"reason": "Mapping definition for [my_field] has unsupported parameters: [fielddata : true]"
}
],
"type": "mapper_parsing_exception",
"reason": "Failed to parse mapping [doc]: Mapping definition for [my_field] has unsupported parameters: [fielddata : true]",
"caused_by": {
"type": "mapper_parsing_exception",
"reason": "Mapping definition for [my_field] has unsupported parameters: [fielddata : true]"
}
},
"status": 400
}
问题在于,如果没有fielddata
进行排序,就不会正确进行。例如,以下是示例asc
排序输出:
"90000001"
"90000001"
""
""
""
"90000008"
"9100000"
答案 0 :(得分:0)
您无需为fielddata: true
字段设置keyword
。您还可以删除index: true
,因为它是keyword
字段的默认设置:
就像这样:
{
"index_patterns": "*",
"mappings": {
"doc": {
"_source": {
"enabled": true
},
"properties": {
"my_field": {
"type": "keyword"
}
}
}
}
}