Package org.apache.lucene.search
Class ByteVectorSimilarityQuery.Adaptive
java.lang.Object
org.apache.lucene.search.Query
org.apache.lucene.search.ByteVectorSimilarityQuery
org.apache.lucene.search.ByteVectorSimilarityQuery.Adaptive
- Enclosing class:
ByteVectorSimilarityQuery
A
ByteVectorSimilarityQuery with an adaptive threshold for graph traversal.-
Nested Class Summary
Nested classes/interfaces inherited from class org.apache.lucene.search.ByteVectorSimilarityQuery
ByteVectorSimilarityQuery.Adaptive, ByteVectorSimilarityQuery.Explicit -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final floatprotected final Stringprotected final Queryprotected final floatprotected final KnnSearchStrategy -
Constructor Summary
ConstructorsConstructorDescriptionSearch for all (approximate) byte vectors above a similarity threshold usingVectorSimilarityCollector.Search for all (approximate) byte vectors above a similarity threshold usingVectorSimilarityCollector, with the defaultKnnSearchStrategy.Adaptive(String field, byte[] target, float resultSimilarity, float decay, Query filter, KnnSearchStrategy searchStrategy) Search for all (approximate) byte vectors above a similarity threshold usingVectorSimilarityCollector, with a caller-suppliedKnnSearchStrategy.Search for all (approximate) byte vectors above a similarity threshold usingVectorSimilarityCollector. -
Method Summary
Modifier and TypeMethodDescriptioncreateWeight(IndexSearcher searcher, ScoreMode scoreMode, float boost) Expert: Constructs an appropriate Weight implementation for this query.protected KnnCollectorManagerReturns aKnnCollectorManagerthat always builds aVectorSimilarityCollectorconfigured with this query'ssearchStrategy.Prints a query to a string, withfieldassumed to be the default field and omitted.voidvisit(QueryVisitor visitor) Recurse through the query tree, visiting any child queries.Methods inherited from class org.apache.lucene.search.ByteVectorSimilarityQuery
approximateSearch, equals, hashCodeMethods inherited from class org.apache.lucene.search.Query
classHash, rewrite, sameClassAs, toString
-
Field Details
-
field
-
resultSimilarity
protected final float resultSimilarity -
decay
protected final float decay -
filter
-
searchStrategy
-
-
Constructor Details
-
Adaptive
public Adaptive(String field, byte[] target, float resultSimilarity, float decay, Query filter, KnnSearchStrategy searchStrategy) Search for all (approximate) byte vectors above a similarity threshold usingVectorSimilarityCollector, with a caller-suppliedKnnSearchStrategy. If a filter is applied, it traverses as many nodes as the cost of the filter, and then falls back to exact search if results are incomplete.- Parameters:
field- a field that has been indexed as aKnnByteVectorField.target- the target of the search.resultSimilarity- similarity score for result collection.decay- decay factor for graph traversal buffer.filter- a filter applied before the vector search.searchStrategy- theKnnSearchStrategyto use during graph search. Ifnull, this query's own default is used: anKnnSearchStrategy.HnswwithfilteredSearchThreshold == 0, which preserves this query's filter handling. Note this differs fromKnnSearchStrategy.Hnsw.DEFAULT, which uses a threshold of 60. The underlying format may not support all strategies and is free to ignore the requested strategy.
-
Adaptive
Search for all (approximate) byte vectors above a similarity threshold usingVectorSimilarityCollector, with the defaultKnnSearchStrategy. If a filter is applied, it traverses as many nodes as the cost of the filter, and then falls back to exact search if results are incomplete.- Parameters:
field- a field that has been indexed as aKnnByteVectorField.target- the target of the search.resultSimilarity- similarity score for result collection.decay- decay factor for graph traversal buffer.filter- a filter applied before the vector search.
-
Adaptive
Search for all (approximate) byte vectors above a similarity threshold usingVectorSimilarityCollector. If a filter is applied, it traverses as many nodes as the cost of the filter, and then falls back to exact search if results are incomplete.- Parameters:
field- a field that has been indexed as aKnnByteVectorField.target- the target of the search.resultSimilarity- similarity score for result collection.filter- a filter applied before the vector search.
-
Adaptive
Search for all (approximate) byte vectors above a similarity threshold usingVectorSimilarityCollector.- Parameters:
field- a field that has been indexed as aKnnByteVectorField.target- the target of the search.resultSimilarity- similarity score for result collection.
-
-
Method Details
-
toString
Description copied from class:QueryPrints a query to a string, withfieldassumed to be the default field and omitted. -
getKnnCollectorManager
Returns aKnnCollectorManagerthat always builds aVectorSimilarityCollectorconfigured with this query'ssearchStrategy.The manager's
strategyandLeafReaderContextparameters are intentionally ignored: top-k queries may override the strategy on a per-search basis, but similarity- threshold queries pin the strategy to the query's own value at construction time so thatQuery.equals(java.lang.Object)/getSearchStrategy()remain a faithful description of search behavior. -
getSearchStrategy
- Returns:
- the
KnnSearchStrategyused during graph search.
-
createWeight
public Weight createWeight(IndexSearcher searcher, ScoreMode scoreMode, float boost) throws IOException Description copied from class:QueryExpert: Constructs an appropriate Weight implementation for this query.Only implemented by primitive queries, which re-write to themselves.
- Overrides:
createWeightin classQuery- Parameters:
scoreMode- How the produced scorers will be consumed.boost- The boost that is propagated by the parent queries.- Throws:
IOException
-
visit
Description copied from class:QueryRecurse through the query tree, visiting any child queries.
-