Fielddata is disabled on text fields by default. Set fielddata=true on [XXX] in order to load fielddata in memory by uninverting the inverted index.
1、报错信息:
Fielddata is disabled on text fields by default. Set fielddata=true on [createTime
] in order to load fielddata in memory by uninverting the inverted index. Note that this can however use significant memory. Alternatively use a keyword field instead.
2、翻译如下:
默认情况下在文本字段中禁用 Fielddata。在字段 [createTime
] 上设置 fielddata=true,以便通过不反转反转索引将 fielddata 加载到内存中。注意,这可能会使用大量内存,或者使用关键字 [keyWord] 字段代替。
3、报错原因:
ElasticSearch 5.x 版本之后将 String 类型去掉了,以 text 和 keyWord 代替。
官方解释如下:https://www.elastic.co/guide/en/elasticsearch/reference/current/fielddata.html
4、如何解决:
PUT 你的index/_mapping/你的type/
{
"properties": {
"你的字段": {
"type": "text或keyWord",
"fielddata": true
}
}
}
修改报错中提到的字段类型,修改为 text 或 keyWord。以 createTime 字段为例:
PUT 我的index/_mapping/我的type/
{
"properties": {
"createTime": {
"type": "text",
"fielddata": true
}
}
}