Namespace Lucene.Net.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 values <xref:Lucene.Net.Facet.Taxonomy.TaxonomyFacetSumIntAssociations>, <xref:Lucene.Net.Facet.Taxonomy.TaxonomyFacetSumFloatAssociations>, TaxonomyFacetSumValueSource. Add FacetField or AssociationFacetField to 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 (<xref:Lucene.Net.Facet.Sortedset.SortedSetDocValuesFacetCounts>). Add <xref:Lucene.Net.Facet.Sortedset.SortedSetDocValuesFacetField> to your documents at index time to use sorted set facet counts. * Range faceting <xref:Lucene.Net.Facet.Range.LongRangeFacetCounts>, DoubleRangeFacetCounts compute counts for a dynamic numeric range from a provided ValueSource (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 #search 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.
Classes
DrillDownQuery
A Query for drill-down over facet categories. You should call Add(String, String[]) for every group of categories you want to drill-down over.
NOTE: if you choose to create your own Query by calling
Term(String, String, String[]), it is recommended to wrap it with ConstantScoreQuery
and set the Boost to 0.0f
,
so that it does not affect the scores of the documents.
DrillSideways
Computes drill down and sideways counts for the provided DrillDownQuery. Drill sideways counts include alternative values/aggregates for the drill-down dimensions so that a dimension does not disappear after the user drills down into it.
Use one of the static search methods to do the search, and then get the hits and facet results from the returned DrillSidewaysResult.
NOTE: this allocates one FacetsCollector for each drill-down, plus one. If your index has high number of facet labels then this will multiply your memory usage. @lucene.experimental
DrillSidewaysResult
Result of a drill sideways search, including the Facets and TopDocs.
FacetField
Add an instance of this to your Document for every facet label.
NOTE: you must call Build(Document) before you add the document to IndexWriter.
FacetResult
Counts or aggregates for a single dimension.
Facets
Common base class for all facets implementations.
FacetsCollector
Collects hits for subsequent faceting. Once you've run a search and collect hits into this, instantiate one of the ICollector subclasses to do the facet counting. Use the Search utility methods (such as Search(IndexSearcher, Query, Int32, ICollector)) to perform an "ordinary" search but also collect into a Facets.
FacetsCollector.Docs
Used during collection to record matching docs and then return a DocIdSet that contains them.
FacetsCollector.MatchingDocs
Holds the documents that were matched in the AtomicReaderContext.
If scores were required, then Scores is not null
.
FacetsConfig
Records per-dimension configuration. By default a dimension is flat, single valued and does not require count for the dimension; use the setters in this class to change these settings for each dim.
NOTE: this configuration is not saved into the index, but it's vital, and up to the application to ensure, that at search time the provided FacetsConfig matches what was used during indexing. @lucene.experimental
FacetsConfig.DimConfig
Holds the configuration for one dimension
LabelAndValue
Single label and its value, usually contained in a FacetResult.
MultiFacets
Maps specified dims to provided Facets impls; else, uses the default Facets impl.
RandomSamplingFacetsCollector
Collects hits for subsequent faceting, using sampling if needed. Once you've
run a search and collect hits into this, instantiate one of the
Facets subclasses to do the facet counting. Note that this collector
does not collect the scores of matching docs (i.e.
Scores) is null
.
If you require the original set of hits, you can call GetOriginalMatchingDocs(). Also, since the counts of the top-facets is based on the sampled set, you can amortize the counts by calling AmortizeFacetCounts(FacetResult, FacetsConfig, IndexSearcher).
TopOrdAndInt32Queue
Keeps highest results, first by largest System.Int32 value, then tie break by smallest ord.
NOTE: This was TopOrdAndIntQueue in Lucene
TopOrdAndInt32Queue.OrdAndValue
Holds a single entry.
TopOrdAndSingleQueue
Keeps highest results, first by largest System.Single value, then tie break by smallest ord.
NOTE: This was TopOrdAndFloatQueue in Lucene
TopOrdAndSingleQueue.OrdAndValue
Holds a single entry.