Package org.apache.lucene.search
Class ByteVectorSimilarityQuery
java.lang.Object
org.apache.lucene.search.Query
org.apache.lucene.search.ByteVectorSimilarityQuery
- Direct Known Subclasses:
ByteVectorSimilarityQuery.Adaptive,ByteVectorSimilarityQuery.Explicit
public abstract sealed class ByteVectorSimilarityQuery
extends Query
permits ByteVectorSimilarityQuery.Adaptive, ByteVectorSimilarityQuery.Explicit
Search for all (approximate) byte vectors above a similarity threshold.
- WARNING: This API is experimental and might change in incompatible ways in the next release.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classAByteVectorSimilarityQuerywith an adaptive threshold for graph traversal.static classDeprecated. -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final floatprotected final Stringprotected final Queryprotected final floatprotected final KnnSearchStrategy -
Method Summary
Modifier and TypeMethodDescriptionprotected TopDocsapproximateSearch(LeafReaderContext context, AcceptDocs acceptDocs, int visitLimit, KnnCollectorManager knnCollectorManager) createWeight(IndexSearcher searcher, ScoreMode scoreMode, float boost) Expert: Constructs an appropriate Weight implementation for this query.booleanOverride and implement query instance equivalence properly in a subclass.protected KnnCollectorManagerReturns aKnnCollectorManagerthat always builds aVectorSimilarityCollectorconfigured with this query'ssearchStrategy.inthashCode()Override and implement query hash code properly in a subclass.voidvisit(QueryVisitor visitor) Recurse through the query tree, visiting any child queries.
-
Field Details
-
field
-
resultSimilarity
protected final float resultSimilarity -
decay
protected final float decay -
filter
-
searchStrategy
-
-
Method Details
-
approximateSearch
protected TopDocs approximateSearch(LeafReaderContext context, AcceptDocs acceptDocs, int visitLimit, KnnCollectorManager knnCollectorManager) throws IOException - Throws:
IOException
-
equals
Description copied from class:QueryOverride and implement query instance equivalence properly in a subclass. This is required so thatQueryCacheworks properly.Typically a query will be equal to another only if it's an instance of the same class and its document-filtering properties are identical to those of the other instance. Utility methods are provided for certain repetitive code.
- See Also:
-
hashCode
public int hashCode()Description copied from class:QueryOverride and implement query hash code properly in a subclass. This is required so thatQueryCacheworks properly.- See Also:
-
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.
-
ByteVectorSimilarityQueryconstructors in Lucene 10.4 and earlier, useByteVectorSimilarityQuery.Adaptivefor a more performant version.