Q:非洲食人族的酋长吃什么?

聚合时查询条件没有起作用

Elasticsearch | 作者 lxh | 发布于2018年05月11日 | 阅读数:2577

聚合时,设置的查询条件没有起作用

searchRequestBuilder.setTypes(ESTransportClient.getIndexType());
// 设置查询类型 1.SearchType.DFS_QUERY_THEN_FETCH = 精确查询 2.SearchType.SCAN
searchRequestBuilder.setSearchType(SearchType.DFS_QUERY_THEN_FETCH);
// 设置查询关键词
QueryBuilder matchQuery = QueryBuilders.multiMatchQuery(keyword, "content", "title", "summary")
.type(Type.MOST_FIELDS);
searchRequestBuilder.setQuery(matchQuery);
//searchRequestBuilder.setQuery(QueryBuilders.termQuery("searchType", SearchTypeConstant.SOFTWARE));
searchRequestBuilder.setSize(0);
// QueryBuilders.t
searchRequestBuilder.setPostFilter(QueryBuilders.termQuery("searchType", SearchTypeConstant.SOFTWARE));
searchRequestBuilder.addAggregation(AggregationBuilders.terms("category_count").field("categoryId"));
searchRequestBuilder.addAggregation(AggregationBuilders.terms("product_count").field("productId"));
searchRequestBuilder.addAggregation(AggregationBuilders.terms("attr_count").field("attr"));
SearchResponse response = searchRequestBuilder.execute().actionGet();

已邀请:

laoyang360 - 《一本书讲透Elasticsearch》作者,Elastic认证工程师 [死磕Elasitcsearch]知识星球地址:http://t.cn/RmwM3N9;微信公众号:铭毅天下; 博客:https://elastic.blog.csdn.net

赞同来自:

把dsl打印出来 相关问题一目了然

要回复问题请先登录注册