Package org.apache.lucene.facet
faceted search
This module provides multiple methods for computing facet counts and value aggregations:
- Taxonomy-based methods rely on a separate taxonomy index to
map hierarchical facet paths to global int ordinals for fast
counting at search time; these methods can compute counts
((
FastTaxonomyFacetCounts,TaxonomyFacetCounts) aggregate long or double valuesTaxonomyFacetSumIntAssociations,TaxonomyFacetSumFloatAssociations,TaxonomyFacetSumValueSource. AddFacetFieldorAssociationFacetFieldto your documents at index time to use taxonomy-based methods. - Sorted-set doc values method does not require a separate
taxonomy index, and computes counts based on sorted set doc
values fields (
SortedSetDocValuesFacetCounts). AddSortedSetDocValuesFacetFieldto your documents at index time to use sorted set facet counts. - Range faceting
LongRangeFacetCounts,DoubleRangeFacetCountscompute counts for a dynamic numeric range from a providedValueSource(previously indexed numeric field, or a dynamic expression such as distance).
At search time you first run your search, but pass a FacetsCollector to gather all hits (and optionally, scores for each
hit). Then, instantiate whichever facet methods you'd like to use
to compute aggregates. Finally, all methods implement a common
Facets base API that you use to obtain specific facet
counts.
The various FacetsCollector.search(org.apache.lucene.search.IndexSearcher, org.apache.lucene.search.Query, int, org.apache.lucene.search.Collector) utility methods are
useful for doing an "ordinary" search (sorting by score, or by a
specified Sort) but also collecting into a FacetsCollector for
subsequent faceting.
-
Class Summary Class Description DrillDownQuery AQueryfor drill-down over facet categories.DrillSideways Computes drill down and sideways counts for the providedDrillDownQuery.DrillSideways.DrillSidewaysResult FacetField Add an instance of this to yourDocumentfor every facet label.FacetResult Counts or aggregates for a single dimension.Facets Common base class for all facets implementations.FacetsCollector Collects hits for subsequent faceting.FacetsCollector.MatchingDocs Holds the documents that were matched in theAtomicReaderContext.FacetsConfig Records per-dimension configuration.FacetsConfig.DimConfig Holds the configuration for one dimensionLabelAndValue Single label and its value, usually contained in aFacetResult.MultiFacets Maps specified dims to provided Facets impls; else, uses the default Facets impl.TopOrdAndFloatQueue Keeps highest results, first by largest float value, then tie break by smallest ord.TopOrdAndFloatQueue.OrdAndValue Holds a single entry.TopOrdAndIntQueue Keeps highest results, first by largest int value, then tie break by smallest ord.TopOrdAndIntQueue.OrdAndValue Holds a single entry.