Package com.yahoo.search.predicate
Class PredicateIndexBuilder
- java.lang.Object
-
- com.yahoo.search.predicate.PredicateIndexBuilder
-
@Beta public class PredicateIndexBuilder extends Object
A builder forPredicateIndex
.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 thePredicate
objects usingPredicate.fromString(String)
.Use
build()
to create an instance ofPredicateIndex
.- Author:
- bjorncs
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
PredicateIndexBuilder.PredicateIndexStats
A collection of metrics about the currently builtPredicateIndex
.
-
Constructor Summary
Constructors Constructor Description PredicateIndexBuilder(int arity)
Creates a PredicateIndexBuilder with default upper and lower bounds.PredicateIndexBuilder(int arity, long lowerBound, long upperBound)
Creates a PredicateIndexBuilder.PredicateIndexBuilder(Config config)
Creates a PredicateIndexBuilder based on a Config object.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description PredicateIndex
build()
PredicateIndexBuilder.PredicateIndexStats
getStats()
Retrieves metrics about the current index.int
getZeroConstraintDocCount()
void
indexDocument(int docId, com.yahoo.document.predicate.Predicate predicate)
Indexes a predicate with the given id.
-
-
-
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 predicatesupperBound
- 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 matchespredicate
- the predicate to index
-
build
public PredicateIndex build()
-
getZeroConstraintDocCount
public int getZeroConstraintDocCount()
-
getStats
public PredicateIndexBuilder.PredicateIndexStats getStats()
Retrieves metrics about the current index.- Returns:
- an object containing metrics
-
-