WARNING: Deprecated in 7.15.0.
The Java REST Client is deprecated in favor of the Java API Client.
Using Java Builders
edit
IMPORTANT: This documentation is no longer updated. Refer to Elastic's version policy and the latest documentation.
Using Java Builders
editThe Java High Level REST Client depends on the Elasticsearch core project which provides
different types of Java Builders objects, including:
- Query Builders
-
The query builders are used to create the query to execute within a search request. There
is a query builder for every type of query supported by the Query DSL. Each query builder
implements the
QueryBuilderinterface and allows to set the specific options for a given type of query. Once created, theQueryBuilderobject can be set as the query parameter ofSearchSourceBuilder. The Search Request page shows an example of how to build a full search request usingSearchSourceBuilderandQueryBuilderobjects. The Building Search Queries page gives a list of all available search queries with their correspondingQueryBuilderobjects andQueryBuildershelper methods. - Aggregation Builders
-
Similarly to query builders, the aggregation builders are used to create the aggregations to
compute during a search request execution. There is an aggregation builder for every type of
aggregation (or pipeline aggregation) supported by Elasticsearch. All builders extend the
AggregationBuilderclass (orPipelineAggregationBuilder`class). Once created, `AggregationBuilderobjects can be set as the aggregation parameter ofSearchSourceBuilder. There is a example of howAggregationBuilderobjects are used withSearchSourceBuilderobjects to define the aggregations to compute with a search query in Search Request page. The Building Aggregations page gives a list of all available aggregations with their correspondingAggregationBuilderobjects andAggregationBuildershelper methods.