当前位置:   article > 正文

spring data elasticsearch term 聚合问题

termsaggregationbuilder tostring 异常

 

terms  的聚合操作:
TermsAggregationBuilder termsAggregationBuilder = AggregationBuilders.terms("xxx").field("xxx");
有错误:

{ "error" : "JsonGenerationException[Can not write a field name, expecting a value]"}

解决办法:
0 实际可以不用管,忽略
1 在SearchResponse的toString()的内容如下, 这个内容就是查询的JSON结果,这里面的JSON结果的结构与SearchResponse的API操作相配套使用可以获取到里面的每一个值。

 

agg聚合后提示:

"message": "Could not write JSON: show_terms_doc_count_error is false; nested exception is com.fasterxml.jackson.databind.JsonMappingException: show_terms_doc_count_error is false (through reference chain: org.springframework.data.elasticsearch.core.aggregation.impl.AggregatedPageImpl[\"aggregations\"]->org.elasticsearch.search.aggregations.InternalAggregations[\"asMap\"]->java.util.Collections$UnmodifiableMap[\"campaign\"]->org.elasticsearch.search.aggregations.bucket.terms.LongTerms[\"buckets\"]->java.util.ArrayList[0]->org.elasticsearch.search.aggregations.bucket.terms.LongTerms$Bucket[\"docCountError\"])",
参考:
https://www.elastic.co/guide/en/elasticsearch/reference/5.6/search-aggregations-bucket-terms-aggregation.html#_per_bucket_document_count_error

设置:
termsAggregationBuilder.showTermDocCountError(true);

就可以解决

 

转载于:https://www.cnblogs.com/jellyabd/p/9848179.html

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/寸_铁/article/detail/774462
推荐阅读
相关标签
  

闽ICP备14008679号