Class FacetsAccumulator

  • Direct Known Subclasses:
    SamplingWrapper, StandardFacetsAccumulator

    public abstract class FacetsAccumulator
    extends Object
    Driver for Accumulating facets of faceted search requests over given documents.
    WARNING: This API is experimental and might change in incompatible ways in the next release.
    • Constructor Detail

      • FacetsAccumulator

        public FacetsAccumulator​(FacetSearchParams searchParams,
                                 org.apache.lucene.index.IndexReader indexReader,
                                 TaxonomyReader taxonomyReader)
    • Method Detail

      • accumulate

        public abstract List<FacetResult> accumulate​(ScoredDocIDs docids)
                                              throws IOException
        Accumulate facets over given documents, according to facet requests in effect.
        Parameters:
        docids - documents (and their scores) for which facets are Accumulated.
        Returns:
        Accumulated facets.
        Throws:
        IOException - on error.
      • setComplementThreshold

        public void setComplementThreshold​(double complementThreshold)
        Set 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 IndexReader implements both IndexReader.directory() and IndexReader.getVersion() otherwise the optimization is silently disabled regardless of the complement threshold settings.

        For the default settings see DEFAULT_COMPLEMENT_THRESHOLD.

        To forcing complements in all cases pass 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 DISABLE_COMPLEMENT.

        Parameters:
        complementThreshold - the complement threshold to set
      • isAllowLabeling

        protected boolean isAllowLabeling()
        Check 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.

        Returns:
        true of labeling is allowed for this accumulator
        See Also:
        setAllowLabeling(boolean)
      • setAllowLabeling

        protected void setAllowLabeling​(boolean allowLabeling)
        Set whether labeling is allowed for this accumulator.
        Parameters:
        allowLabeling - new setting for allow labeling
        See Also:
        isAllowLabeling()
      • mayComplement

        protected boolean mayComplement()
        check if all requests are complementable