java.lang.Object
org.elasticsearch.search.vectors.KnnSearchBuilder
- All Implemented Interfaces:
Writeable,Rewriteable<KnnSearchBuilder>,ToXContent,ToXContentFragment
public class KnnSearchBuilder
extends Object
implements Writeable, ToXContentFragment, Rewriteable<KnnSearchBuilder>
Defines a kNN search to run in the search request.
-
Nested Class Summary
Nested ClassesNested classes/interfaces inherited from interface org.elasticsearch.xcontent.ToXContent
ToXContent.DelegatingMapParams, ToXContent.MapParams, ToXContent.ParamsNested classes/interfaces inherited from interface org.elasticsearch.common.io.stream.Writeable
Writeable.Reader<V>, Writeable.Writer<V> -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final ParseFieldstatic final ParseFieldstatic final ParseFieldstatic final ParseFieldstatic final ParseFieldstatic final ParseFieldstatic final ParseFieldstatic final intstatic final floatstatic final ParseFieldstatic final ParseFieldstatic final ParseFieldstatic final ParseFieldFields inherited from interface org.elasticsearch.index.query.Rewriteable
MAX_REWRITE_ROUNDSFields inherited from interface org.elasticsearch.xcontent.ToXContent
EMPTY, EMPTY_PARAMS -
Constructor Summary
ConstructorsConstructorDescriptionKnnSearchBuilder(String field, float[] queryVector, int k, int numCands, RescoreVectorBuilder rescoreVectorBuilder, Float similarity) Defines a kNN search.KnnSearchBuilder(String field, QueryVectorBuilder queryVectorBuilder, int k, int numCands, RescoreVectorBuilder rescoreVectorBuilder, Float similarity) Defines a kNN search where the query vector will be provided by the queryVectorBuilderKnnSearchBuilder(String field, VectorData queryVector, int k, int numCands, RescoreVectorBuilder rescoreVectorBuilder, Float similarity) Defines a kNN search.KnnSearchBuilder(String field, VectorData queryVector, QueryVectorBuilder queryVectorBuilder, int k, int numCands, RescoreVectorBuilder rescoreVectorBuilder, Float similarity) -
Method Summary
Modifier and TypeMethodDescriptionaddFilterQueries(List<QueryBuilder> filterQueries) addFilterQuery(QueryBuilder filterQuery) floatboost()boost(float boost) Set a boost to apply to the kNN search scores.booleanstatic KnnSearchBuilder.BuilderfromXContent(XContentParser parser) getField()intinthashCode()innerHit()innerHit(InnerHitBuilder innerHitBuilder) intk()Sets a query name for the kNN search query.Rewrites this instance based on the provided context.toXContent(XContentBuilder builder, ToXContent.Params params) voidwriteTo(StreamOutput out) Write this into the StreamOutput.Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.elasticsearch.xcontent.ToXContentFragment
isFragment
-
Field Details
-
NUM_CANDS_LIMIT
public static final int NUM_CANDS_LIMIT- See Also:
-
NUM_CANDS_MULTIPLICATIVE_FACTOR
public static final float NUM_CANDS_MULTIPLICATIVE_FACTOR- See Also:
-
FIELD_FIELD
-
K_FIELD
-
NUM_CANDS_FIELD
-
QUERY_VECTOR_FIELD
-
QUERY_VECTOR_BUILDER_FIELD
-
VECTOR_SIMILARITY
-
FILTER_FIELD
-
NAME_FIELD
-
BOOST_FIELD
-
INNER_HITS_FIELD
-
RESCORE_VECTOR_FIELD
-
-
Constructor Details
-
KnnSearchBuilder
public KnnSearchBuilder(String field, float[] queryVector, int k, int numCands, RescoreVectorBuilder rescoreVectorBuilder, Float similarity) Defines a kNN search.- Parameters:
field- the name of the vector field to search againstqueryVector- the query vectork- the final number of nearest neighbors to return as top hitsnumCands- the number of nearest neighbor candidates to consider per shardrescoreVectorBuilder- rescore vector information
-
KnnSearchBuilder
public KnnSearchBuilder(String field, VectorData queryVector, int k, int numCands, RescoreVectorBuilder rescoreVectorBuilder, Float similarity) Defines a kNN search.- Parameters:
field- the name of the vector field to search againstqueryVector- the query vectork- the final number of nearest neighbors to return as top hitsnumCands- the number of nearest neighbor candidates to consider per shard
-
KnnSearchBuilder
public KnnSearchBuilder(String field, QueryVectorBuilder queryVectorBuilder, int k, int numCands, RescoreVectorBuilder rescoreVectorBuilder, Float similarity) Defines a kNN search where the query vector will be provided by the queryVectorBuilder- Parameters:
field- the name of the vector field to search againstqueryVectorBuilder- the query vector builderk- the final number of nearest neighbors to return as top hitsnumCands- the number of nearest neighbor candidates to consider per shard
-
KnnSearchBuilder
public KnnSearchBuilder(String field, VectorData queryVector, QueryVectorBuilder queryVectorBuilder, int k, int numCands, RescoreVectorBuilder rescoreVectorBuilder, Float similarity) -
KnnSearchBuilder
- Throws:
IOException
-
-
Method Details
-
fromXContent
- Throws:
IOException
-
k
public int k() -
getNumCands
public int getNumCands() -
getRescoreVectorBuilder
-
getQueryVectorBuilder
-
getQueryVector
-
getField
-
getFilterQueries
-
addFilterQuery
-
addFilterQueries
-
queryName
Sets a query name for the kNN search query. -
queryName
-
boost
Set a boost to apply to the kNN search scores. -
boost
public float boost() -
innerHit
-
innerHit
-
rewrite
Description copied from interface:RewriteableRewrites this instance based on the provided context. The returned objects will be the same instance as this if no changes during the rewrite were applied.- Specified by:
rewritein interfaceRewriteable<KnnSearchBuilder>- Throws:
IOException
-
toQueryBuilder
-
getSimilarity
-
equals
-
hashCode
public int hashCode() -
toXContent
public XContentBuilder toXContent(XContentBuilder builder, ToXContent.Params params) throws IOException - Specified by:
toXContentin interfaceToXContent- Throws:
IOException
-
writeTo
Description copied from interface:WriteableWrite this into the StreamOutput.- Specified by:
writeToin interfaceWriteable- Throws:
IOException
-