Class SamplingWrapper
- java.lang.Object
-
- org.apache.lucene.facet.search.FacetsAccumulator
-
- org.apache.lucene.facet.search.SamplingWrapper
-
public class SamplingWrapper extends FacetsAccumulator
Wrap any Facets Accumulator with sampling.Note: Sampling accumulation (Accumulation over a sampled-set of the results), does not guarantee accurate values for
FacetResult.getNumValidDescendants()&FacetResultNode.getResidue().- WARNING: This API is experimental and might change in incompatible ways in the next release.
-
-
Field Summary
-
Fields inherited from class org.apache.lucene.facet.search.FacetsAccumulator
DEFAULT_COMPLEMENT_THRESHOLD, DISABLE_COMPLEMENT, FORCE_COMPLEMENT, indexReader, searchParams, taxonomyReader
-
-
Constructor Summary
Constructors Constructor Description SamplingWrapper(FacetsAccumulator delegee, Sampler sampler)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description List<FacetResult>accumulate(ScoredDocIDs docids)Accumulate facets over given documents, according to facet requests in effect.doublegetComplementThreshold()protected booleanisAllowLabeling()Check if labeling is allowed for this accumulator.protected voidsetAllowLabeling(boolean allowLabeling)Set whether labeling is allowed for this accumulator.voidsetComplementThreshold(double complementThreshold)Set the complement threshold.-
Methods inherited from class org.apache.lucene.facet.search.FacetsAccumulator
mayComplement
-
-
-
-
Constructor Detail
-
SamplingWrapper
public SamplingWrapper(FacetsAccumulator delegee, Sampler sampler)
-
-
Method Detail
-
accumulate
public List<FacetResult> accumulate(ScoredDocIDs docids) throws IOException
Description copied from class:FacetsAccumulatorAccumulate facets over given documents, according to facet requests in effect.- Specified by:
accumulatein classFacetsAccumulator- Parameters:
docids- documents (and their scores) for which facets are Accumulated.- Returns:
- Accumulated facets.
- Throws:
IOException- on error.
-
getComplementThreshold
public double getComplementThreshold()
- Overrides:
getComplementThresholdin classFacetsAccumulator- Returns:
- the complement threshold
- See Also:
FacetsAccumulator.getComplementThreshold()
-
setComplementThreshold
public void setComplementThreshold(double complementThreshold)
Description copied from class:FacetsAccumulatorSet the complement threshold. This threshold will dictate whether the complements optimization is applied. The optimization is to count for less documents. It is useful when the same FacetSearchParams are used for varying sets of documents. The first time complements is used the "total counts" are computed - counting for all the documents in the collection. Then, only the complementing set of documents is considered, and used to decrement from the overall counts, thereby walking through less documents, which is faster.Note that this optimization is only available when searching an index whose
IndexReaderimplements bothIndexReader.directory()andIndexReader.getVersion()otherwise the optimization is silently disabled regardless of the complement threshold settings.For the default settings see
FacetsAccumulator.DEFAULT_COMPLEMENT_THRESHOLD.To forcing complements in all cases pass
FacetsAccumulator.FORCE_COMPLEMENT. This is mostly useful for testing purposes, as forcing complements when only tiny fraction of available documents match the query does not make sense and would incur performance degradations.To disable complements pass
FacetsAccumulator.DISABLE_COMPLEMENT.- Overrides:
setComplementThresholdin classFacetsAccumulator- Parameters:
complementThreshold-- See Also:
FacetsAccumulator.setComplementThreshold(double)
-
isAllowLabeling
protected boolean isAllowLabeling()
Description copied from class:FacetsAccumulatorCheck if labeling is allowed for this accumulator.By default labeling is allowed. This allows one accumulator to invoke other accumulators for accumulation but keep to itself the responsibility of labeling. This might br handy since labeling is a costly operation.
- Overrides:
isAllowLabelingin classFacetsAccumulator- Returns:
- true of labeling is allowed for this accumulator
- See Also:
FacetsAccumulator.setAllowLabeling(boolean)
-
setAllowLabeling
protected void setAllowLabeling(boolean allowLabeling)
Description copied from class:FacetsAccumulatorSet whether labeling is allowed for this accumulator.- Overrides:
setAllowLabelingin classFacetsAccumulator- Parameters:
allowLabeling- new setting for allow labeling- See Also:
FacetsAccumulator.isAllowLabeling()
-
-