记录:使用ES的聚合和Filter遇到的问题(已解决)
NativeSearchQueryBuilder queryBuilder = new NativeSearchQueryBuilder() .withIndices("vehicle_illegal_information") .**withFilter**(QueryBuilders.boolQuery() .must(QueryBuilders.matchPhraseQuery("name.keyword", companyName))) .addAggregation(format) .addAggregation(AggregationBuilders.terms("group_by_number").field("vehicleNumber.keyword").size(10)) .withPageable(PageRequest.of(0, 1000)) .withSort(SortBuilders.fieldSort("publishTime").order(SortOrder.DESC));
使用addAggregation和withFilter条件的时候会忽略withfiler的查询条件,查询全部数据
解决方案:withFilter->withQuery withQuery的条件不会呗忽略掉,暂时没有去探求是什么原因。
posted on 2020-12-23 16:48 放弃容易坚持一定很帅 阅读(908) 评论(0) 编辑 收藏 举报