简体   繁体   English

如何使用Java API获得所有字段的方面值

[英]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.

相关问题 如何使用 Java 在一个 Go 中获取多个字段的值? - How to get value of multiple fields in one Go using Java? 如何在Java中使用Lightcouch API从CouchDB中获取所有文档 - How to get all documents from couchdb using lightcouch api in java Elasticsearch-Java RestHighLevelClient-如何使用滚动API获取所有文档 - Elasticsearch - Java RestHighLevelClient - how to get all documents using scroll api 使用 Java API 在 Elasticsearch 的所有字段中搜索多个字符串 - Searching multiple strings in all fields in Elasticsearch using Java API 如何使用Java使用Selenium WebDriver获取所有跨度值? - How to get all the span value with Selenium WebDriver using Java? 使用反射-如何获取所有字段和方法 - Using reflection - how to get all fields and methods 如何使用Java中的API获取特定的值或数据 - How to get a specific Value or Data using the API in Java 如何使用 java 和 jackson api 获取 @JsonProperty 的值? - How to get @JsonProperty 's value using java and jackson api? 如何在Java中解析对象并获取其所有数据成员和字段? - How to parse an object and get all its data members and fields in java? 如何获取所有字段以及Composite对象的值? - How to get all fields along with value of Composite object?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM