Class PredicateIndexBuilder


  • @Beta
    public class PredicateIndexBuilder
    extends java.lang.Object
    A builder for PredicateIndex.

    When creating a PredicateIndexBuilder, you must specify an arity. This is used for range features, and is a trade-off of index size vs. query speed. Higher arities gives larger index but faster search.

    indexDocument(int, Predicate) takes a document id and a predicate to insert into the index. Predicates should be specified using the predicate syntax described in the documentation. Create the Predicate objects using Predicate.fromString(String).

    Use build() to create an instance of PredicateIndex.

    Author:
    bjorncs
    • Constructor Detail

      • PredicateIndexBuilder

        public PredicateIndexBuilder​(int arity)
        Creates a PredicateIndexBuilder with default upper and lower bounds.
        Parameters:
        arity - the arity to use when indexing range predicates. Small arity gives smaller index, but more expensive searches.
      • PredicateIndexBuilder

        public PredicateIndexBuilder​(int arity,
                                     long lowerBound,
                                     long upperBound)
        Creates a PredicateIndexBuilder. Limiting the range of possible values in range predicates reduces index size and increases search performance.
        Parameters:
        arity - the arity to use when indexing range predicates. Small arity gives smaller index, but more expensive searches.
        lowerBound - the lower bound for the range of values used by range predicates
        upperBound - the upper bound for the range of values used by range predicates
      • PredicateIndexBuilder

        public PredicateIndexBuilder​(Config config)
        Creates a PredicateIndexBuilder based on a Config object.
        Parameters:
        config - configuration for the PredicateIndexBuilder
    • Method Detail

      • indexDocument

        public void indexDocument​(int docId,
                                  com.yahoo.document.predicate.Predicate predicate)
        Indexes a predicate with the given id.
        Parameters:
        docId - a 32-bit document id, returned in the Hit objects when the predicate matches
        predicate - the predicate to index
      • getZeroConstraintDocCount

        public int getZeroConstraintDocCount()