IMPORTANT: No additional bug fixes or documentation updates
will be released for this version. For the latest information, see the
current release documentation.
Facets
edit
IMPORTANT: This documentation is no longer updated. Refer to Elastic's version policy and the latest documentation.
Facets
editElasticsearch provides a full Java API to play with facets. See the Facets guide.
Use the factory for facet builders (FacetBuilders) and add each facet
you want to compute when querying and add it to your search request:
SearchResponse sr = node.client().prepareSearch()
.setQuery( /* your query */ )
.addFacet( /* add a facet */ )
.execute().actionGet();
Note that you can add more than one facet. See Search Java API for details.
To build facet requests, use FacetBuilders helpers. Just import them
in your class:
import org.elasticsearch.search.facet.FacetBuilders.*;