Package org.apache.lucene.facet
Class Facets
- java.lang.Object
-
- org.apache.lucene.facet.Facets
-
- Direct Known Subclasses:
ConcurrentSortedSetDocValuesFacetCounts
,DoubleRangeFacetCounts
,LongRangeFacetCounts
,LongValueFacetCounts
,MatchingFacetSetsCounts
,MultiFacets
,SortedSetDocValuesFacetCounts
,StringValueFacetCounts
,TaxonomyFacets
public abstract class Facets extends Object
Common base class for all facets implementations.- WARNING: This API is experimental and might change in incompatible ways in the next release.
-
-
Constructor Summary
Constructors Constructor Description Facets()
Default constructor.
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description abstract FacetResult
getAllChildren(String dim, String... path)
Returns all child labels with non-zero counts under the specified path.abstract 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.abstract Number
getSpecificValue(String dim, String... path)
Return the count or value for a specific path.abstract FacetResult
getTopChildren(int topN, String dim, String... path)
Returns the topN child labels under the specified path.List<FacetResult>
getTopDims(int topNDims, int topNChildren)
Returns labels for topN dimensions and their topNChildren sorted by the number of hits/aggregated values that dimension matched.protected static void
validateTopN(int topN)
This helper method checks if topN is valid for getTopChildren and getAllDims.
-
-
-
Method Detail
-
getAllChildren
public abstract FacetResult getAllChildren(String dim, String... path) throws IOException
Returns 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.- Throws:
IOException
-
getTopChildren
public abstract FacetResult getTopChildren(int topN, String dim, String... path) throws IOException
Returns the topN child labels under the specified path. Returns null if the specified path doesn't exist or if this dimension was never seen.- Throws:
IOException
-
getSpecificValue
public abstract Number getSpecificValue(String dim, String... path) throws IOException
Return the count or value for a specific path. Returns -1 if this path doesn't exist, else the count.- Throws:
IOException
-
getAllDims
public abstract List<FacetResult> getAllDims(int topN) throws IOException
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.- Throws:
IOException
-
getTopDims
public List<FacetResult> getTopDims(int topNDims, int topNChildren) throws IOException
Returns labels for topN dimensions and their topNChildren sorted by the number of hits/aggregated values that dimension matched. Results should be the same as calling getAllDims and then only using the first topNDims. Note that dims should be configured as requiring dim counts if using this functionality to ensure accurate counts are available (see:FacetsConfig.setRequireDimCount(String, boolean)
).Sub-classes may want to override this implementation with a more efficient one if they are able.
- Throws:
IOException
-
validateTopN
protected static void validateTopN(int topN)
This helper method checks if topN is valid for getTopChildren and getAllDims. Throws IllegalArgumentException if topN is invalid.- WARNING: This API is experimental and might change in incompatible ways in the next release.
- it may not exist in future versions of Lucene
-
-