Package com.yahoo.search.predicate
Class PredicateIndexBuilder
java.lang.Object
com.yahoo.search.predicate.PredicateIndexBuilder
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
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
A collection of metrics about the currently builtPredicateIndex
. -
Constructor Summary
ConstructorDescriptionPredicateIndexBuilder
(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
Modifier and TypeMethodDescriptionbuild()
getStats()
Retrieves metrics about the current index.int
void
indexDocument
(int docId, com.yahoo.document.predicate.Predicate predicate) Indexes a predicate with the given id.
-
Constructor Details
-
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
Creates a PredicateIndexBuilder based on a Config object.- Parameters:
config
- configuration for the PredicateIndexBuilder
-
-
Method Details
-
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
-
getZeroConstraintDocCount
public int getZeroConstraintDocCount() -
getStats
Retrieves metrics about the current index.- Returns:
- an object containing metrics
-