From 84399d01db5a4e3c68014234f3eb4411d2a22fa2 Mon Sep 17 00:00:00 2001 From: Laura Trotta <153528055+l-trotta@users.noreply.github.com> Date: Fri, 9 Aug 2024 17:41:38 +0200 Subject: [PATCH] adding k to knn search (#2781) --- output/openapi/elasticsearch-openapi.json | 4 ++++ .../elasticsearch-serverless-openapi.json | 4 ++++ output/schema/schema-serverless.json | 18 +++++++++++++++--- output/schema/schema.json | 18 +++++++++++++++--- output/typescript/types.ts | 1 + specification/_types/Knn.ts | 2 ++ 6 files changed, 41 insertions(+), 6 deletions(-) diff --git a/output/openapi/elasticsearch-openapi.json b/output/openapi/elasticsearch-openapi.json index f88d354873..b8234638b7 100644 --- a/output/openapi/elasticsearch-openapi.json +++ b/output/openapi/elasticsearch-openapi.json @@ -60813,6 +60813,10 @@ "description": "The number of nearest neighbor candidates to consider per shard", "type": "number" }, + "k": { + "description": "The final number of nearest neighbors to return as top hits", + "type": "number" + }, "filter": { "description": "Filters for the kNN search query", "oneOf": [ diff --git a/output/openapi/elasticsearch-serverless-openapi.json b/output/openapi/elasticsearch-serverless-openapi.json index c0ae885749..4d36a8160c 100644 --- a/output/openapi/elasticsearch-serverless-openapi.json +++ b/output/openapi/elasticsearch-serverless-openapi.json @@ -37343,6 +37343,10 @@ "description": "The number of nearest neighbor candidates to consider per shard", "type": "number" }, + "k": { + "description": "The final number of nearest neighbors to return as top hits", + "type": "number" + }, "filter": { "description": "Filters for the kNN search query", "oneOf": [ diff --git a/output/schema/schema-serverless.json b/output/schema/schema-serverless.json index b6d26d2a06..81efed3ac2 100644 --- a/output/schema/schema-serverless.json +++ b/output/schema/schema-serverless.json @@ -54825,6 +54825,18 @@ } } }, + { + "description": "The final number of nearest neighbors to return as top hits", + "name": "k", + "required": false, + "type": { + "kind": "instance_of", + "type": { + "name": "integer", + "namespace": "_types" + } + } + }, { "description": "Filters for the kNN search query", "name": "filter", @@ -54865,7 +54877,7 @@ } } ], - "specLocation": "_types/Knn.ts#L54-L67" + "specLocation": "_types/Knn.ts#L54-L69" }, { "kind": "type_alias", @@ -54904,7 +54916,7 @@ } } ], - "specLocation": "_types/Knn.ts#L69-L72", + "specLocation": "_types/Knn.ts#L71-L74", "variants": { "kind": "container" } @@ -54939,7 +54951,7 @@ } } ], - "specLocation": "_types/Knn.ts#L74-L77" + "specLocation": "_types/Knn.ts#L76-L79" }, { "inherits": { diff --git a/output/schema/schema.json b/output/schema/schema.json index 58c12c21cf..eeb292f9fc 100644 --- a/output/schema/schema.json +++ b/output/schema/schema.json @@ -44317,6 +44317,18 @@ } } }, + { + "description": "The final number of nearest neighbors to return as top hits", + "name": "k", + "required": false, + "type": { + "kind": "instance_of", + "type": { + "name": "integer", + "namespace": "_types" + } + } + }, { "description": "Filters for the kNN search query", "name": "filter", @@ -44357,7 +44369,7 @@ } } ], - "specLocation": "_types/Knn.ts#L54-L67" + "specLocation": "_types/Knn.ts#L54-L69" }, { "inherits": { @@ -45922,7 +45934,7 @@ } } ], - "specLocation": "_types/Knn.ts#L69-L72", + "specLocation": "_types/Knn.ts#L71-L74", "variants": { "kind": "container" } @@ -48403,7 +48415,7 @@ } } ], - "specLocation": "_types/Knn.ts#L74-L77" + "specLocation": "_types/Knn.ts#L76-L79" }, { "kind": "enum", diff --git a/output/typescript/types.ts b/output/typescript/types.ts index 47f10776c6..08b6dd051f 100644 --- a/output/typescript/types.ts +++ b/output/typescript/types.ts @@ -2363,6 +2363,7 @@ export interface KnnQuery extends QueryDslQueryBase { query_vector?: QueryVector query_vector_builder?: QueryVectorBuilder num_candidates?: integer + k?: integer filter?: QueryDslQueryContainer | QueryDslQueryContainer[] similarity?: float } diff --git a/specification/_types/Knn.ts b/specification/_types/Knn.ts index 461801bd31..cf9c71cfd7 100644 --- a/specification/_types/Knn.ts +++ b/specification/_types/Knn.ts @@ -60,6 +60,8 @@ export interface KnnQuery extends QueryBase { query_vector_builder?: QueryVectorBuilder /** The number of nearest neighbor candidates to consider per shard */ num_candidates?: integer + /** The final number of nearest neighbors to return as top hits */ + k?: integer /** Filters for the kNN search query */ filter?: QueryContainer | QueryContainer[] /** The minimum similarity for a vector to be considered a match */