[英]How to get facet value for all fields using Java API
I'm new to Elasticsearch
and tried to query some sample documents. 我是
Elasticsearch
新手,并尝试查询一些示例文档。 I issued the following query using the Java API
. 我使用
Java API
发出了以下查询。 This query fetched me the correct result. 该查询获取了正确的结果。 It returned the names of all categories.
它返回所有类别的名称。 Now I want the count of all names of a category.
现在,我要计算一个类别的所有名称。 Could you explain me how to do that?
您能解释一下该怎么做吗? I'm sorry for my bad English.
对不起,我的英语不好。
SearchResponse sr = client.prepareSearch()
.addField("Category")
.setQuery(QueryBuilders.matchAllQuery())
.addFacet(FacetBuilders.termsFacet("f")
.field("Category"))
.execute()
.actionGet();
Look at the Count API to count your results if you not want to get the result set (matched documents) but only the count. 如果您不想获取结果集(匹配的文档),而仅获取计数,请查看Count API对结果进行计数。
If you want to get the result set, you get the result size in the response for every filter or query request too. 如果要获取结果集,则也将在每个过滤器或查询请求的响应中获取结果大小。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.