Package org.apache.lucene.facet
Class LongValueFacetCounts
java.lang.Object
org.apache.lucene.facet.Facets
org.apache.lucene.facet.LongValueFacetCounts
Facets implementation that computes counts for all unique long values, more efficiently
counting small values (0-1023) using an int array, and switching to a HashMap for
values above 1023. Retrieve all facet counts, in value order, with getAllChildrenSortByValue(), or get all children with no ordering requirements with getAllChildren(String, String...), or get the topN values sorted by count with getTopChildren(int, String, String...).- WARNING: This API is experimental and might change in incompatible ways in the next release.
-
Constructor Summary
ConstructorsConstructorDescriptionLongValueFacetCounts(String field, FacetsCollector hits) CreateLongValueFacetCounts, using either single-valuedNumericDocValuesor multi-valuedSortedNumericDocValuesfrom the specified field (depending on what has been indexed).LongValueFacetCounts(String field, MultiLongValuesSource valuesSource, FacetsCollector hits) CreateLongValueFacetCounts, using the providedMultiLongValuesSourceif non-null.LongValueFacetCounts(String field, MultiLongValuesSource valuesSource, IndexReader reader) Counts all facet values for the providedMultiLongValuesSourceif non-null.LongValueFacetCounts(String field, IndexReader reader) Counts all facet values for this reader.LongValueFacetCounts(String field, LongValuesSource valueSource, FacetsCollector hits) CreateLongValueFacetCounts, using the providedLongValuesSourceif non-null.LongValueFacetCounts(String field, LongValuesSource valueSource, IndexReader reader) Counts all facet values for the providedLongValuesSourceif non-null. -
Method Summary
Modifier and TypeMethodDescriptiongetAllChildren(String dim, String... path) Returns all child labels with non-zero counts under the specified path.Returns all unique values seen, sorted by value.getAllDims(int topN) Returns topN labels for any dimension that had hits, sorted by the number of hits that dimension matched; this is used for "sparse" faceting, where many different dimensions were indexed, for example depending on the type of document.getSpecificValue(String dim, String... path) Return the count or value for a specific path.getTopChildren(int topN, String dim, String... path) Returns the topN child labels under the specified path.toString()Methods inherited from class org.apache.lucene.facet.Facets
getTopDims, validateTopN
-
Constructor Details
-
LongValueFacetCounts
CreateLongValueFacetCounts, using either single-valuedNumericDocValuesor multi-valuedSortedNumericDocValuesfrom the specified field (depending on what has been indexed).- Throws:
IOException
-
LongValueFacetCounts
public LongValueFacetCounts(String field, LongValuesSource valueSource, FacetsCollector hits) throws IOException CreateLongValueFacetCounts, using the providedLongValuesSourceif non-null. IfvalueSourceis null, doc values from the providedfieldwill be used.- Throws:
IOException
-
LongValueFacetCounts
public LongValueFacetCounts(String field, MultiLongValuesSource valuesSource, FacetsCollector hits) throws IOException CreateLongValueFacetCounts, using the providedMultiLongValuesSourceif non-null. IfvaluesSourceis null, doc values from the providedfieldwill be used.- Throws:
IOException
-
LongValueFacetCounts
Counts all facet values for this reader. This produces the same result as computing facets on aMatchAllDocsQuery, but is more efficient.- Throws:
IOException
-
LongValueFacetCounts
public LongValueFacetCounts(String field, LongValuesSource valueSource, IndexReader reader) throws IOException Counts all facet values for the providedLongValuesSourceif non-null. IfvalueSourceis null, doc values from the providedfieldwill be used. This produces the same result as computing facets on aMatchAllDocsQuery, but is more efficient.- Throws:
IOException
-
LongValueFacetCounts
public LongValueFacetCounts(String field, MultiLongValuesSource valuesSource, IndexReader reader) throws IOException Counts all facet values for the providedMultiLongValuesSourceif non-null. IfvalueSourceis null, doc values from the providedfieldwill be used. This produces the same result as computing facets on aMatchAllDocsQuery, but is more efficient.- Throws:
IOException
-
-
Method Details
-
getAllChildren
Description copied from class:FacetsReturns all child labels with non-zero counts under the specified path. Users should make no assumptions about ordering of the children. Returns null if the specified path doesn't exist or if this dimension was never seen.- Specified by:
getAllChildrenin classFacets- Throws:
IOException
-
getTopChildren
Description copied from class:FacetsReturns the topN child labels under the specified path. Returns null if the specified path doesn't exist or if this dimension was never seen.- Specified by:
getTopChildrenin classFacets
-
getAllChildrenSortByValue
Returns all unique values seen, sorted by value. This functionality is very similar togetAllChildren(String, String...), but it guarantees the returned values will be sorted by value (while#getAllChildrendoesn't guarantee any sort order).Note: If you don't care about the order of children returned, it may be slightly more efficient to use
getAllChildren(String, String...). -
getSpecificValue
Description copied from class:FacetsReturn the count or value for a specific path. Returns -1 if this path doesn't exist, else the count.- Specified by:
getSpecificValuein classFacets
-
getAllDims
Description copied from class:FacetsReturns topN labels for any dimension that had hits, sorted by the number of hits that dimension matched; this is used for "sparse" faceting, where many different dimensions were indexed, for example depending on the type of document.- Specified by:
getAllDimsin classFacets
-
toString
-