Module org.apache.lucene.facet
Class AbstractSortedSetDocValueFacetCounts
java.lang.Object
org.apache.lucene.facet.Facets
org.apache.lucene.facet.sortedset.AbstractSortedSetDocValueFacetCounts
- Direct Known Subclasses:
ConcurrentSortedSetDocValuesFacetCounts
,SortedSetDocValuesFacetCounts
Base class for SSDV faceting implementations.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescription(package private) static final class
(package private) static final class
private static class
Intermediate result to store top children for a given path before resolving labels, etc. -
Field Summary
FieldsModifier and TypeFieldDescription(package private) final SortedSetDocValues
(package private) final String
(package private) final SortedSetDocValuesReaderState
(package private) final FacetsConfig
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate int
adjustPathCountIfNecessary
(FacetsConfig.DimConfig dimConfig, int pathOrd, int computedCount) computeTopChildren
(PrimitiveIterator.OfInt childOrds, int topN, FacetsConfig.DimConfig dimConfig, int pathOrd) Compute the top-n children for the given path and iterator of all immediate children of the path.private FacetResult
createFacetResult
(AbstractSortedSetDocValueFacetCounts.TopChildrenForPath topChildrenForPath, String dim, String... path) Create a FacetResult for the provided dim + path and intermediate results.getAllChildren
(String dim, String... path) Returns all child labels with non-zero counts under the specified path.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.(package private) abstract int
getCount
(int ord) Retrieve the count for a specified ordinal.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.getTopChildrenForPath
(int topN, String dim, String... path) Determine the top-n children for a specified dimension + path.getTopDims
(int topNDims, int topNChildren) Returns labels for topN dimensions and their topNChildren sorted by the number of hits/aggregated values that dimension matched.(package private) abstract boolean
Were any counts actually computed? (They may not be if there are no hits, etc.)prepareChildIteration
(String dim, FacetsConfig.DimConfig dimConfig, String... path) Determine the path ord and resolve an iterator to its immediate children.Methods inherited from class org.apache.lucene.facet.Facets
validateTopN
-
Field Details
-
state
-
stateConfig
-
dv
-
field
-
-
Constructor Details
-
AbstractSortedSetDocValueFacetCounts
AbstractSortedSetDocValueFacetCounts(SortedSetDocValuesReaderState state) throws IOException - Throws:
IOException
-
-
Method Details
-
getTopChildren
Description copied from class:Facets
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.- Specified by:
getTopChildren
in classFacets
- Throws:
IOException
-
getAllChildren
Description copied from class:Facets
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.- Specified by:
getAllChildren
in classFacets
- Throws:
IOException
-
getSpecificValue
Description copied from class:Facets
Return the count or value for a specific path. Returns -1 if this path doesn't exist, else the count.- Specified by:
getSpecificValue
in classFacets
- Throws:
IOException
-
getAllDims
Description copied from class:Facets
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.- Specified by:
getAllDims
in classFacets
- Throws:
IOException
-
getTopDims
Description copied from class:Facets
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.
- Overrides:
getTopDims
in classFacets
- Throws:
IOException
-
hasCounts
abstract boolean hasCounts()Were any counts actually computed? (They may not be if there are no hits, etc.) -
getCount
abstract int getCount(int ord) Retrieve the count for a specified ordinal. -
prepareChildIteration
private AbstractSortedSetDocValueFacetCounts.ChildIterationCursor prepareChildIteration(String dim, FacetsConfig.DimConfig dimConfig, String... path) throws IOException Determine the path ord and resolve an iterator to its immediate children. The logic for this depends on whether-or-not the dimension is configured as hierarchical.- Throws:
IOException
-
getTopChildrenForPath
private AbstractSortedSetDocValueFacetCounts.TopChildrenForPath getTopChildrenForPath(int topN, String dim, String... path) throws IOException Determine the top-n children for a specified dimension + path. Results are in an intermediate form.- Throws:
IOException
-
computeTopChildren
private AbstractSortedSetDocValueFacetCounts.TopChildrenForPath computeTopChildren(PrimitiveIterator.OfInt childOrds, int topN, FacetsConfig.DimConfig dimConfig, int pathOrd) Compute the top-n children for the given path and iterator of all immediate children of the path. This returns an intermediate result that does the minimal required work, avoiding the cost of looking up string labels, etc. -
adjustPathCountIfNecessary
private int adjustPathCountIfNecessary(FacetsConfig.DimConfig dimConfig, int pathOrd, int computedCount) -
createFacetResult
private FacetResult createFacetResult(AbstractSortedSetDocValueFacetCounts.TopChildrenForPath topChildrenForPath, String dim, String... path) throws IOException Create a FacetResult for the provided dim + path and intermediate results. Does the extra work of resolving ordinals -> labels, etc. Will return null if there are no children.- Throws:
IOException
-