ES关键字排序报错 reason=Fielddata is disabled on text fields by default. Set fielddata=true on 关键字 in order
Posted smile-yan
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了ES关键字排序报错 reason=Fielddata is disabled on text fields by default. Set fielddata=true on 关键字 in order相关的知识,希望对你有一定的参考价值。
问题描述
在使用 java 编写 ES 的查询接口的时候,需要根据某关键字进行排序并返回数据,但是在排序的时候报错如下:
ElasticsearchStatusException[Elasticsearch exception [type=search_phase_execution_exception, reason=all shards failed]
]; nested: ElasticsearchException[Elasticsearch exception [type=illegal_argument_exception, reason=Fielddata is disabled on text fields by default. Set fielddata=true on [subTaskId] 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.]]; nested: ElasticsearchException[Elasticsearch exception [type=illegal_argument_exception, reason=Fielddata is disabled on text fields by default. Set fielddata=true on [subTaskId] 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.]];
at org.elasticsearch.rest.BytesRestResponse.errorFromXContent(BytesRestResponse.java:177)
at org.elasticsearch.client.RestHighLevelClient.parseEntity(RestHighLevelClient.java:1793)
at org.elasticsearch.client.RestHighLevelClient.parseResponseException(RestHighLevelClient.java:1769)
at org.elasticsearch.client.RestHighLevelClient.internalPerformRequest(RestHighLevelClient.java:1606)
at org.elasticsearch.client.RestHighLevelClient.performRequest(RestHighLevelClient.java:1563)
解决方法
使用 谷歌的 Elastic Search Head 插件,然后执行以下命令:
"properties":
"subTaskId":
"type": "text",
"fielddata": true
然后点击左下角的 Request
。
总结
问题虽小,但是也挺烦心的。
Smileyan
2021.11.19 17:37
以上是关于ES关键字排序报错 reason=Fielddata is disabled on text fields by default. Set fielddata=true on 关键字 in order的主要内容,如果未能解决你的问题,请参考以下文章
ES关键字排序报错 reason=Fielddata is disabled on text fields by default. Set fielddata=true on 关键字 in order
VM虚拟机启动报错Reason Failed to lock the file怎么办