Package org.apache.lucene.facet.taxonomy
Class TaxonomyFacetFloatAssociations
java.lang.Object
org.apache.lucene.facet.Facets
org.apache.lucene.facet.taxonomy.TaxonomyFacetFloatAssociations
Aggregates float values associated with facet fields. Supports two different approaches:
- Fields can be indexed with
FloatAssociationFacetField, associating weights with facet values at indexing time. - Fields can be indexed with
FacetFieldand aDoubleValuesSourcecan dynamically supply a weight from each doc. With this approach, the document's weight gets contributed to each facet value associated with the doc.
FloatAssociationFacetField.- WARNING: This API is experimental and might change in incompatible ways in the next release.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final AssociationAggregationFunctionAggregation function used for combining values.protected Comparator<Number> -
Constructor Summary
ConstructorsConstructorDescriptionTaxonomyFacetFloatAssociations(String indexFieldName, TaxonomyReader taxoReader, FacetsConfig config, FacetsCollector fc, AssociationAggregationFunction aggregationFunction) CreateTaxonomyFacetFloatAssociationsagainst the specified index field.TaxonomyFacetFloatAssociations(String indexFieldName, TaxonomyReader taxoReader, FacetsConfig config, FacetsCollector fc, AssociationAggregationFunction aggregationFunction, DoubleValuesSource valuesSource) CreateTaxonomyFacetFloatAssociationsagainst the specified index field.TaxonomyFacetFloatAssociations(TaxonomyReader taxoReader, FacetsConfig config, FacetsCollector fc, AssociationAggregationFunction aggregationFunction) CreateTaxonomyFacetFloatAssociationsagainst the default index field.TaxonomyFacetFloatAssociations(TaxonomyReader taxoReader, FacetsConfig config, FacetsCollector fc, AssociationAggregationFunction aggregationFunction, DoubleValuesSource valuesSource) CreateTaxonomyFacetFloatAssociationsagainst the default index field. -
Method Summary
Modifier and TypeMethodDescriptionprotected NumberApply an aggregation to the two values and return the result.booleanReturns true if the (costly, and lazily initialized) children int[] was initialized.protected NumbergetAggregationValue(int ordinal) Get the aggregation value for this ordinal.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.protected intgetCount(int ordinal) Get the count for this 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.protected org.apache.lucene.facet.taxonomy.TaxonomyFacets.TopChildrenForPathgetTopChildrenForPath(FacetsConfig.DimConfig dimConfig, int pathOrd, int topN) 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.protected voidprotected TopOrdAndNumberQueue.OrdAndValueinsertIntoQueue(TopOrdAndNumberQueue q, TopOrdAndNumberQueue.OrdAndValue incomingOrdAndValue, int ord) protected TopOrdAndNumberQueuemakeTopOrdAndNumberQueue(int topN) Return aTopOrdAndNumberQueueof the appropriate type, i.e.protected NumberReturn the value for a missing aggregation, i.e.protected org.apache.lucene.facet.taxonomy.TaxonomyFacets.AggregatedValueprotected voidsetCount(int ordinal, int newValue) Set the count for this ordinal tonewValue.protected voidsetIncomingValue(TopOrdAndNumberQueue.OrdAndValue incomingOrdAndValue, int ord) booleanReturns true if the (costly, and lazily initialized) sibling int[] was initialized.protected voidupdateValueFromRollup(int ordinal, int childOrdinal) Roll-up the aggregation values fromchildOrdinaltoordinal.Methods inherited from class org.apache.lucene.facet.Facets
validateTopN
-
Field Details
-
aggregationFunction
Aggregation function used for combining values. -
valueComparator
-
-
Constructor Details
-
TaxonomyFacetFloatAssociations
public TaxonomyFacetFloatAssociations(TaxonomyReader taxoReader, FacetsConfig config, FacetsCollector fc, AssociationAggregationFunction aggregationFunction) throws IOException CreateTaxonomyFacetFloatAssociationsagainst the default index field.- Throws:
IOException
-
TaxonomyFacetFloatAssociations
public TaxonomyFacetFloatAssociations(TaxonomyReader taxoReader, FacetsConfig config, FacetsCollector fc, AssociationAggregationFunction aggregationFunction, DoubleValuesSource valuesSource) throws IOException CreateTaxonomyFacetFloatAssociationsagainst the default index field. Sources values from the providedvaluesSource.- Throws:
IOException
-
TaxonomyFacetFloatAssociations
public TaxonomyFacetFloatAssociations(String indexFieldName, TaxonomyReader taxoReader, FacetsConfig config, FacetsCollector fc, AssociationAggregationFunction aggregationFunction) throws IOException CreateTaxonomyFacetFloatAssociationsagainst the specified index field.- Throws:
IOException
-
TaxonomyFacetFloatAssociations
public TaxonomyFacetFloatAssociations(String indexFieldName, TaxonomyReader taxoReader, FacetsConfig config, FacetsCollector fc, AssociationAggregationFunction aggregationFunction, DoubleValuesSource valuesSource) throws IOException CreateTaxonomyFacetFloatAssociationsagainst the specified index field. Sources values from the providedvaluesSource.- Throws:
IOException
-
-
Method Details
-
initializeValueCounters
protected void initializeValueCounters() -
getAggregationValue
Get the aggregation value for this ordinal. -
aggregate
Apply an aggregation to the two values and return the result. -
updateValueFromRollup
Roll-up the aggregation values fromchildOrdinaltoordinal. Overrides should probably call this to update the counts. Overriding allows us to work with primitive types for the aggregation values, keeping aggregation efficient.- Throws:
IOException
-
makeTopOrdAndNumberQueue
Return aTopOrdAndNumberQueueof the appropriate type, i.e. aTopOrdAndIntQueueor aTopOrdAndFloatQueue. -
missingAggregationValue
Return the value for a missing aggregation, i.e.-1or-1f. -
setIncomingValue
-
newAggregatedValue
protected org.apache.lucene.facet.taxonomy.TaxonomyFacets.AggregatedValue newAggregatedValue() -
setCount
protected void setCount(int ordinal, int newValue) Set the count for this ordinal tonewValue. -
getCount
protected int getCount(int ordinal) Get the count for this ordinal. -
childrenLoaded
public boolean childrenLoaded()Returns true if the (costly, and lazily initialized) children int[] was initialized.- WARNING: This API is experimental and might change in incompatible ways in the next release.
-
siblingsLoaded
public boolean siblingsLoaded()Returns true if the (costly, and lazily initialized) sibling int[] was initialized.- WARNING: This API is experimental and might change in incompatible ways in the next release.
-
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
-
insertIntoQueue
protected TopOrdAndNumberQueue.OrdAndValue insertIntoQueue(TopOrdAndNumberQueue q, TopOrdAndNumberQueue.OrdAndValue incomingOrdAndValue, int ord) -
getTopChildrenForPath
protected org.apache.lucene.facet.taxonomy.TaxonomyFacets.TopChildrenForPath getTopChildrenForPath(FacetsConfig.DimConfig dimConfig, int pathOrd, int topN) throws IOException Determine the top-n children for a specified dimension + path. Results are in an intermediate form.- 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- Throws:
IOException
-
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- Throws:
IOException
-
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- Throws:
IOException
-
getTopDims
Description copied from class:FacetsReturns 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:
getTopDimsin classFacets- Throws:
IOException
-