- java.lang.Object
-
- org.apache.lucene.search.Query
-
- org.apache.lucene.search.AbstractVectorSimilarityQuery
-
- org.apache.lucene.search.FloatVectorSimilarityQuery
-
public class FloatVectorSimilarityQuery extends AbstractVectorSimilarityQuery
Search for all (approximate) float vectors above a similarity threshold.
-
-
Field Summary
Fields Modifier and Type Field Description private float[]
target
-
Fields inherited from class org.apache.lucene.search.AbstractVectorSimilarityQuery
field, filter, resultSimilarity, traversalSimilarity
-
-
Constructor Summary
Constructors Constructor Description FloatVectorSimilarityQuery(java.lang.String field, float[] target, float resultSimilarity)
Search for all (approximate) float vectors above a similarity threshold usingVectorSimilarityCollector
.FloatVectorSimilarityQuery(java.lang.String field, float[] target, float traversalSimilarity, float resultSimilarity)
Search for all (approximate) float vectors above a similarity threshold usingVectorSimilarityCollector
.FloatVectorSimilarityQuery(java.lang.String field, float[] target, float traversalSimilarity, float resultSimilarity, Query filter)
Search for all (approximate) float vectors above a similarity threshold usingVectorSimilarityCollector
.FloatVectorSimilarityQuery(java.lang.String field, float[] target, float resultSimilarity, Query filter)
Search for all (approximate) float vectors above a similarity threshold usingVectorSimilarityCollector
.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected TopDocs
approximateSearch(LeafReaderContext context, Bits acceptDocs, int visitLimit)
(package private) VectorScorer
createVectorScorer(LeafReaderContext context)
boolean
equals(java.lang.Object o)
Override and implement query instance equivalence properly in a subclass.int
hashCode()
Override and implement query hash code properly in a subclass.java.lang.String
toString(java.lang.String field)
Prints a query to a string, withfield
assumed to be the default field and omitted.-
Methods inherited from class org.apache.lucene.search.AbstractVectorSimilarityQuery
createWeight, visit
-
-
-
-
Constructor Detail
-
FloatVectorSimilarityQuery
public FloatVectorSimilarityQuery(java.lang.String field, float[] target, float traversalSimilarity, float resultSimilarity, Query filter)
Search for all (approximate) float 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 aKnnFloatVectorField
.target
- the target of the search.traversalSimilarity
- (lower) similarity score for graph traversal.resultSimilarity
- (higher) similarity score for result collection.filter
- a filter applied before the vector search.
-
FloatVectorSimilarityQuery
public FloatVectorSimilarityQuery(java.lang.String field, float[] target, float traversalSimilarity, float resultSimilarity)
Search for all (approximate) float vectors above a similarity threshold usingVectorSimilarityCollector
.- Parameters:
field
- a field that has been indexed as aKnnFloatVectorField
.target
- the target of the search.traversalSimilarity
- (lower) similarity score for graph traversal.resultSimilarity
- (higher) similarity score for result collection.
-
FloatVectorSimilarityQuery
public FloatVectorSimilarityQuery(java.lang.String field, float[] target, float resultSimilarity, Query filter)
Search for all (approximate) float 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 aKnnFloatVectorField
.target
- the target of the search.resultSimilarity
- similarity score for result collection.filter
- a filter applied before the vector search.
-
FloatVectorSimilarityQuery
public FloatVectorSimilarityQuery(java.lang.String field, float[] target, float resultSimilarity)
Search for all (approximate) float vectors above a similarity threshold usingVectorSimilarityCollector
.- Parameters:
field
- a field that has been indexed as aKnnFloatVectorField
.target
- the target of the search.resultSimilarity
- similarity score for result collection.
-
-
Method Detail
-
createVectorScorer
VectorScorer createVectorScorer(LeafReaderContext context) throws java.io.IOException
- Specified by:
createVectorScorer
in classAbstractVectorSimilarityQuery
- Throws:
java.io.IOException
-
approximateSearch
protected TopDocs approximateSearch(LeafReaderContext context, Bits acceptDocs, int visitLimit) throws java.io.IOException
- Specified by:
approximateSearch
in classAbstractVectorSimilarityQuery
- Throws:
java.io.IOException
-
toString
public java.lang.String toString(java.lang.String field)
Description copied from class:Query
Prints a query to a string, withfield
assumed to be the default field and omitted.
-
equals
public boolean equals(java.lang.Object o)
Description copied from class:Query
Override and implement query instance equivalence properly in a subclass. This is required so thatQueryCache
works 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.
- Overrides:
equals
in classAbstractVectorSimilarityQuery
- See Also:
Query.sameClassAs(Object)
,Query.classHash()
-
hashCode
public int hashCode()
Description copied from class:Query
Override and implement query hash code properly in a subclass. This is required so thatQueryCache
works properly.- Overrides:
hashCode
in classAbstractVectorSimilarityQuery
- See Also:
Query.equals(Object)
-
-