当前位置:网站首页>Es keyword sorting error reason = fielddata is disabled on text fields by default Set fielddata = true on keyword in order

Es keyword sorting error reason = fielddata is disabled on text fields by default Set fielddata = true on keyword in order

2022-04-23 20:17:00 smile-yan

Problem description

In the use of java To write ES When querying the interface , You need to sort according to a keyword and return data , However, the errors reported during sorting are as follows :

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)

resolvent

Use Google's Elastic Search Head plug-in unit , Then execute the following command :

{
    
  "properties": {
    
    "subTaskId": {
    
      "type": "text",
      "fielddata": true
    }
  }
}

 Insert picture description here
Then click on the Request.

 Insert picture description here

summary

The problem is small , But it's also very annoying .

Smileyan
2021.11.19 17:37

版权声明
本文为[smile-yan]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204210553133479.html