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 classes/interfaces inherited from interface org.elasticsearch.xcontent.ToXContent
ToXContent.DelegatingMapParams, ToXContent.MapParams, ToXContent.Params
Nested classes/interfaces inherited from interface org.elasticsearch.common.io.stream.Writeable
Writeable.Reader<V>, Writeable.Writer<V>
-
Field Summary
Modifier and TypeFieldDescriptionstatic final ParseField
static final ParseField
static final ParseField
static final ParseField
static final ParseField
static final ParseField
static final int
static final float
static final ParseField
static final ParseField
static final ParseField
Fields inherited from interface org.elasticsearch.index.query.Rewriteable
MAX_REWRITE_ROUNDS
Fields inherited from interface org.elasticsearch.xcontent.ToXContent
EMPTY, EMPTY_PARAMS
-
Constructor Summary
ConstructorDescriptionKnnSearchBuilder
(String field, float[] queryVector, int k, int numCands, Float similarity) Defines a kNN search.KnnSearchBuilder
(String field, float[] queryVector, QueryVectorBuilder queryVectorBuilder, int k, int numCands, Float similarity) KnnSearchBuilder
(String field, QueryVectorBuilder queryVectorBuilder, int k, int numCands, Float similarity) Defines a kNN search where the query vector will be provided by the queryVectorBuilder -
Method Summary
Modifier and TypeMethodDescriptionaddFilterQueries
(List<QueryBuilder> filterQueries) addFilterQuery
(QueryBuilder filterQuery) float
boost()
boost
(float boost) Set a boost to apply to the kNN search scores.boolean
static KnnSearchBuilder.Builder
fromXContent
(XContentParser parser) getField()
float[]
int
hashCode()
innerHit()
innerHit
(InnerHitBuilder innerHitBuilder) int
k()
Rewrites this instance based on the provided context.toXContent
(XContentBuilder builder, ToXContent.Params params) void
writeTo
(StreamOutput out) Write this into the StreamOutput.Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
Methods 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
-
BOOST_FIELD
-
INNER_HITS_FIELD
-
-
Constructor Details
-
KnnSearchBuilder
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, 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, float[] queryVector, QueryVectorBuilder queryVectorBuilder, int k, int numCands, Float similarity) -
KnnSearchBuilder
- Throws:
IOException
-
-
Method Details
-
fromXContent
- Throws:
IOException
-
k
public int k() -
getQueryVectorBuilder
-
getQueryVector
public float[] getQueryVector() -
getField
-
addFilterQuery
-
addFilterQueries
-
boost
Set a boost to apply to the kNN search scores. -
boost
public float boost() -
innerHit
-
innerHit
-
rewrite
Description copied from interface:Rewriteable
Rewrites 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:
rewrite
in interfaceRewriteable<KnnSearchBuilder>
- Throws:
IOException
-
toQueryBuilder
-
equals
-
hashCode
public int hashCode() -
toXContent
public XContentBuilder toXContent(XContentBuilder builder, ToXContent.Params params) throws IOException - Specified by:
toXContent
in interfaceToXContent
- Throws:
IOException
-
writeTo
Description copied from interface:Writeable
Write this into the StreamOutput.- Specified by:
writeTo
in interfaceWriteable
- Throws:
IOException
-