ElasticsearchStatusException[Elasticsearch exception [type=search

ElasticsearchStatusException[Elasticsearch exception [type=search,第1张

ElasticsearchStatusException[Elasticsearch exception [type=search
ElasticsearchStatusException[Elasticsearch exception [type=search_phase_execution_exception, reason=all shards failed]
]; nested: ElasticsearchException[Elasticsearch exception [type=illegal_argument_exception, reason=Text fields are not optimised for operations that require per-document field data like aggregations and sorting, so these operations are disabled by default. Please use a keyword field instead. Alternatively, set fielddata=true on [source] in order to load field data by uninverting the inverted index. Note that this can use significant memory.]]; nested: ElasticsearchException[Elasticsearch exception [type=illegal_argument_exception, reason=Text fields are not optimised for operations that require per-document field data like aggregations and sorting, so these operations are disabled by default. Please use a keyword field instead. Alternatively, set fielddata=true on [source] in order to load field data by uninverting the inverted index. Note that this can use significant memory.]];
	at org.elasticsearch.rest.BytesRestResponse.errorFromXContent(BytesRestResponse.java:177)
	at org.elasticsearch.client.RestHighLevelClient.parseEntity(RestHighLevelClient.java:1888)
	at org.elasticsearch.client.RestHighLevelClient.parseResponseException(RestHighLevelClient.java:1865)
	at org.elasticsearch.client.RestHighLevelClient.internalPerformRequest(RestHighLevelClient.java:1622)
	at org.elasticsearch.client.RestHighLevelClient.performRequest(RestHighLevelClient.java:1579)
	at org.elasticsearch.client.RestHighLevelClient.performRequestAndParseEntity(RestHighLevelClient.java:1549)
	at org.elasticsearch.client.RestHighLevelClient.search(RestHighLevelClient.java:1065)

当使用到term 查询的时候,由于是精准匹配,所以查询的关键字在es上的类型,必须是keyword而不能是text,比如你的搜索条件是 ”name”:”蔡虚坤”,那么该name 字段的es类型得是keyword,而不能是text
在es中,只有keyword类型的字符串可以使用AggregationBuilders.terms("aggs-class")来分组聚合,想要分组查询,指定根据分组字段的keyword属性就可以了

 

 

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/zaji/5678403.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-12-16
下一篇 2022-12-17

发表评论

登录后才能评论

评论列表(0条)

保存