Package org.apache.lucene.facet
Class LongValueFacetCounts
- java.lang.Object
-
- org.apache.lucene.facet.Facets
-
- org.apache.lucene.facet.LongValueFacetCounts
-
public class LongValueFacetCounts extends Facets
Facetsimplementation that computes counts for all unique long values, more efficiently counting small values (0-1023) using an int array, and switching to aHashMapfor values above 1023. Retrieve all facet counts, in value order, withgetAllChildrenSortByValue(), or get the topN values sorted by count withgetTopChildrenSortByCount(int).- WARNING: This API is experimental and might change in incompatible ways in the next release.
-
-
Constructor Summary
Constructors Constructor Description LongValueFacetCounts(String field, FacetsCollector hits, boolean multiValued)CreateLongValueFacetCounts, using either single-valuedNumericDocValuesor multi-valuedSortedNumericDocValuesfrom the specified field.LongValueFacetCounts(String field, IndexReader reader, boolean multiValued)Counts all facet values for this reader.LongValueFacetCounts(String field, LongValuesSource valueSource, FacetsCollector hits)CreateLongValueFacetCounts, using the providedLongValuesSource.LongValueFacetCounts(String field, LongValuesSource valueSource, FacetsCollector hits, boolean multiValued)CreateLongValueFacetCounts, using the providedLongValuesSource.LongValueFacetCounts(String field, LongValuesSource valueSource, IndexReader reader)Counts all facet values for the providedLongValuesSource.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description FacetResultgetAllChildrenSortByValue()Returns all unique values seen, sorted by value.List<FacetResult>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.NumbergetSpecificValue(String dim, String... path)Return the count or value for a specific path.FacetResultgetTopChildren(int topN, String dim, String... path)Returns the topN child labels under the specified path.FacetResultgetTopChildrenSortByCount(int topN)Returns the specified top number of facets, sorted by count.StringtoString()
-
-
-
Constructor Detail
-
LongValueFacetCounts
public LongValueFacetCounts(String field, FacetsCollector hits, boolean multiValued) throws IOException
CreateLongValueFacetCounts, using either single-valuedNumericDocValuesor multi-valuedSortedNumericDocValuesfrom the specified field.- Throws:
IOException
-
LongValueFacetCounts
public LongValueFacetCounts(String field, LongValuesSource valueSource, FacetsCollector hits) throws IOException
CreateLongValueFacetCounts, using the providedLongValuesSource. If hits is null then all facets are counted.- Throws:
IOException
-
LongValueFacetCounts
public LongValueFacetCounts(String field, LongValuesSource valueSource, FacetsCollector hits, boolean multiValued) throws IOException
CreateLongValueFacetCounts, using the providedLongValuesSource. random access (implementDocIdSet.bits()).- Throws:
IOException
-
LongValueFacetCounts
public LongValueFacetCounts(String field, IndexReader reader, boolean multiValued) throws IOException
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 providedLongValuesSource. This produces the same result as computing facets on aMatchAllDocsQuery, but is more efficient.- Throws:
IOException
-
-
Method Detail
-
getTopChildren
public FacetResult getTopChildren(int topN, String dim, String... path)
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
-
getTopChildrenSortByCount
public FacetResult getTopChildrenSortByCount(int topN)
Returns the specified top number of facets, sorted by count.
-
getAllChildrenSortByValue
public FacetResult getAllChildrenSortByValue()
Returns all unique values seen, sorted by value.
-
getSpecificValue
public Number getSpecificValue(String dim, String... path) throws IOException
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- Throws:
IOException
-
getAllDims
public List<FacetResult> getAllDims(int topN) throws IOException
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- Throws:
IOException
-
-