From 9a4d5f2bc4ab65d0929c8606147b1dfc9eb92832 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Peter=20Stra=C3=9Fer?= Date: Thu, 3 Aug 2023 17:09:02 +0200 Subject: [PATCH 1/4] Add missing similarity field to KnnQuery and missing fields to KnnSearchQuery. --- output/schema/schema.json | 85 +++++++++++++++++-- output/typescript/types.ts | 7 +- .../_global/knn_search/_types/Knn.ts | 15 +++- specification/_types/Knn.ts | 2 + 4 files changed, 100 insertions(+), 9 deletions(-) diff --git a/output/schema/schema.json b/output/schema/schema.json index 57e780d7ee..3ce744731b 100644 --- a/output/schema/schema.json +++ b/output/schema/schema.json @@ -25400,7 +25400,7 @@ { "description": "The query vector", "name": "query_vector", - "required": true, + "required": false, "type": { "kind": "instance_of", "type": { @@ -25409,6 +25409,18 @@ } } }, + { + "description": "The query vector builder. You must provide a query_vector_builder or query_vector, but not both.", + "name": "query_vector_builder", + "required": false, + "type": { + "kind": "instance_of", + "type": { + "name": "QueryVectorBuilder", + "namespace": "_types" + } + } + }, { "description": "The final number of nearest neighbors to return as top hits", "name": "k", @@ -25432,9 +25444,60 @@ "namespace": "_types" } } + }, + { + "description": "Boost value to apply to kNN scores", + "name": "boost", + "required": false, + "type": { + "kind": "instance_of", + "type": { + "name": "float", + "namespace": "_types" + } + } + }, + { + "description": "Filters for the kNN search query", + "name": "filter", + "required": false, + "type": { + "items": [ + { + "kind": "instance_of", + "type": { + "name": "QueryContainer", + "namespace": "_types.query_dsl" + } + }, + { + "kind": "array_of", + "value": { + "kind": "instance_of", + "type": { + "name": "QueryContainer", + "namespace": "_types.query_dsl" + } + } + } + ], + "kind": "union_of" + } + }, + { + "description": "The required minimum similarity for a vector to be considered a match", + "name": "similarity", + "required": true, + "type": { + "kind": "instance_of", + "type": { + "name": "double", + "namespace": "_types" + } + } } ], - "specLocation": "_global/knn_search/_types/Knn.ts#L24-L33" + "specLocation": "_global/knn_search/_types/Knn.ts#L25-L42" }, { "kind": "interface", @@ -42376,9 +42439,21 @@ ], "kind": "union_of" } + }, + { + "description": "The required minimum similarity for a vector to be considered a match", + "name": "similarity", + "required": true, + "type": { + "kind": "instance_of", + "type": { + "name": "double", + "namespace": "_types" + } + } } ], - "specLocation": "_types/Knn.ts#L26-L41" + "specLocation": "_types/Knn.ts#L26-L43" }, { "kind": "interface", @@ -43717,7 +43792,7 @@ } } ], - "specLocation": "_types/Knn.ts#L43-L46", + "specLocation": "_types/Knn.ts#L45-L48", "variants": { "kind": "container" } @@ -45895,7 +45970,7 @@ } } ], - "specLocation": "_types/Knn.ts#L48-L51" + "specLocation": "_types/Knn.ts#L50-L53" }, { "kind": "enum", diff --git a/output/typescript/types.ts b/output/typescript/types.ts index 0a53c27778..0d519b09be 100644 --- a/output/typescript/types.ts +++ b/output/typescript/types.ts @@ -667,9 +667,13 @@ export interface KnnSearchResponse { export interface KnnSearchQuery { field: Field - query_vector: QueryVector + query_vector?: QueryVector + query_vector_builder?: QueryVectorBuilder k: long num_candidates: long + boost?: float + filter?: QueryDslQueryContainer | QueryDslQueryContainer[] + similarity: double } export interface MgetMultiGetError { @@ -2322,6 +2326,7 @@ export interface KnnQuery { num_candidates: long boost?: float filter?: QueryDslQueryContainer | QueryDslQueryContainer[] + similarity: double } export interface LatLonGeoLocation { diff --git a/specification/_global/knn_search/_types/Knn.ts b/specification/_global/knn_search/_types/Knn.ts index a23483e51e..83a3099493 100644 --- a/specification/_global/knn_search/_types/Knn.ts +++ b/specification/_global/knn_search/_types/Knn.ts @@ -18,16 +18,25 @@ */ import { Field } from '@_types/common' -import { long, float } from '@_types/Numeric' -import { QueryVector } from '@_types/Knn' +import { long, float, double } from '@_types/Numeric' +import { QueryVector, QueryVectorBuilder } from '@_types/Knn' +import { QueryContainer } from '@_types/query_dsl/abstractions' export interface Query { /** The name of the vector field to search against */ field: Field /** The query vector */ - query_vector: QueryVector + query_vector?: QueryVector + /** The query vector builder. You must provide a query_vector_builder or query_vector, but not both. */ + query_vector_builder?: QueryVectorBuilder /** The final number of nearest neighbors to return as top hits */ k: long /** The number of nearest neighbor candidates to consider per shard */ num_candidates: long + /** Boost value to apply to kNN scores */ + boost?: float + /** Filters for the kNN search query */ + filter?: QueryContainer | QueryContainer[] + /** The required minimum similarity for a vector to be considered a match */ + similarity: double } diff --git a/specification/_types/Knn.ts b/specification/_types/Knn.ts index 2a3b4a9422..eb73be4798 100644 --- a/specification/_types/Knn.ts +++ b/specification/_types/Knn.ts @@ -38,6 +38,8 @@ export interface KnnQuery { boost?: float /** Filters for the kNN search query */ filter?: QueryContainer | QueryContainer[] + /** The required minimum similarity for a vector to be considered a match */ + similarity: double } /** @variants container */ From 6dc5adce24adc6537988c9dfa7cbd8f9470efeef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Peter=20Stra=C3=9Fer?= Date: Mon, 7 Aug 2023 11:19:52 +0200 Subject: [PATCH 2/4] Fixed similarity not being a required field --- output/schema/schema.json | 8 ++++---- output/typescript/types.ts | 4 ++-- specification/_global/knn_search/_types/Knn.ts | 4 ++-- specification/_types/Knn.ts | 4 ++-- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/output/schema/schema.json b/output/schema/schema.json index c9532c78a5..80f99abf87 100644 --- a/output/schema/schema.json +++ b/output/schema/schema.json @@ -25486,9 +25486,9 @@ } }, { - "description": "The required minimum similarity for a vector to be considered a match", + "description": "The minimum similarity for a vector to be considered a match", "name": "similarity", - "required": true, + "required": false, "type": { "kind": "instance_of", "type": { @@ -42445,9 +42445,9 @@ } }, { - "description": "The required minimum similarity for a vector to be considered a match", + "description": "The minimum similarity for a vector to be considered a match", "name": "similarity", - "required": true, + "required": false, "type": { "kind": "instance_of", "type": { diff --git a/output/typescript/types.ts b/output/typescript/types.ts index c7ae36e757..9ce469e9d4 100644 --- a/output/typescript/types.ts +++ b/output/typescript/types.ts @@ -673,7 +673,7 @@ export interface KnnSearchQuery { num_candidates: long boost?: float filter?: QueryDslQueryContainer | QueryDslQueryContainer[] - similarity: double + similarity?: double } export interface MgetMultiGetError { @@ -2326,7 +2326,7 @@ export interface KnnQuery { num_candidates: long boost?: float filter?: QueryDslQueryContainer | QueryDslQueryContainer[] - similarity: double + similarity?: double } export interface LatLonGeoLocation { diff --git a/specification/_global/knn_search/_types/Knn.ts b/specification/_global/knn_search/_types/Knn.ts index 83a3099493..a75ced384e 100644 --- a/specification/_global/knn_search/_types/Knn.ts +++ b/specification/_global/knn_search/_types/Knn.ts @@ -37,6 +37,6 @@ export interface Query { boost?: float /** Filters for the kNN search query */ filter?: QueryContainer | QueryContainer[] - /** The required minimum similarity for a vector to be considered a match */ - similarity: double + /** The minimum similarity for a vector to be considered a match */ + similarity?: double } diff --git a/specification/_types/Knn.ts b/specification/_types/Knn.ts index eb73be4798..6d8e450941 100644 --- a/specification/_types/Knn.ts +++ b/specification/_types/Knn.ts @@ -38,8 +38,8 @@ export interface KnnQuery { boost?: float /** Filters for the kNN search query */ filter?: QueryContainer | QueryContainer[] - /** The required minimum similarity for a vector to be considered a match */ - similarity: double + /** The minimum similarity for a vector to be considered a match */ + similarity?: double } /** @variants container */ From a8ddffed07660429fff91b2e48489571d0102d71 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Peter=20Stra=C3=9Fer?= Date: Thu, 21 Sep 2023 07:43:20 +0200 Subject: [PATCH 3/4] Reverted changes in specification/_global/knn_search/_types/Knn.ts, as this references an old deprecated API --- output/schema/schema.json | 67 +------------------ output/typescript/types.ts | 6 +- .../_global/knn_search/_types/Knn.ts | 15 +---- 3 files changed, 6 insertions(+), 82 deletions(-) diff --git a/output/schema/schema.json b/output/schema/schema.json index aa328f7d4e..a79e0798d6 100644 --- a/output/schema/schema.json +++ b/output/schema/schema.json @@ -25461,7 +25461,7 @@ { "description": "The query vector", "name": "query_vector", - "required": false, + "required": true, "type": { "kind": "instance_of", "type": { @@ -25470,18 +25470,6 @@ } } }, - { - "description": "The query vector builder. You must provide a query_vector_builder or query_vector, but not both.", - "name": "query_vector_builder", - "required": false, - "type": { - "kind": "instance_of", - "type": { - "name": "QueryVectorBuilder", - "namespace": "_types" - } - } - }, { "description": "The final number of nearest neighbors to return as top hits", "name": "k", @@ -25505,60 +25493,9 @@ "namespace": "_types" } } - }, - { - "description": "Boost value to apply to kNN scores", - "name": "boost", - "required": false, - "type": { - "kind": "instance_of", - "type": { - "name": "float", - "namespace": "_types" - } - } - }, - { - "description": "Filters for the kNN search query", - "name": "filter", - "required": false, - "type": { - "items": [ - { - "kind": "instance_of", - "type": { - "name": "QueryContainer", - "namespace": "_types.query_dsl" - } - }, - { - "kind": "array_of", - "value": { - "kind": "instance_of", - "type": { - "name": "QueryContainer", - "namespace": "_types.query_dsl" - } - } - } - ], - "kind": "union_of" - } - }, - { - "description": "The minimum similarity for a vector to be considered a match", - "name": "similarity", - "required": false, - "type": { - "kind": "instance_of", - "type": { - "name": "double", - "namespace": "_types" - } - } } ], - "specLocation": "_global/knn_search/_types/Knn.ts#L25-L42" + "specLocation": "_global/knn_search/_types/Knn.ts#L24-L33" }, { "kind": "interface", diff --git a/output/typescript/types.ts b/output/typescript/types.ts index c4aebede0d..3023e4a20b 100644 --- a/output/typescript/types.ts +++ b/output/typescript/types.ts @@ -668,13 +668,9 @@ export interface KnnSearchResponse { export interface KnnSearchQuery { field: Field - query_vector?: QueryVector - query_vector_builder?: QueryVectorBuilder + query_vector: QueryVector k: long num_candidates: long - boost?: float - filter?: QueryDslQueryContainer | QueryDslQueryContainer[] - similarity?: double } export interface MgetMultiGetError { diff --git a/specification/_global/knn_search/_types/Knn.ts b/specification/_global/knn_search/_types/Knn.ts index a75ced384e..a23483e51e 100644 --- a/specification/_global/knn_search/_types/Knn.ts +++ b/specification/_global/knn_search/_types/Knn.ts @@ -18,25 +18,16 @@ */ import { Field } from '@_types/common' -import { long, float, double } from '@_types/Numeric' -import { QueryVector, QueryVectorBuilder } from '@_types/Knn' -import { QueryContainer } from '@_types/query_dsl/abstractions' +import { long, float } from '@_types/Numeric' +import { QueryVector } from '@_types/Knn' export interface Query { /** The name of the vector field to search against */ field: Field /** The query vector */ - query_vector?: QueryVector - /** The query vector builder. You must provide a query_vector_builder or query_vector, but not both. */ - query_vector_builder?: QueryVectorBuilder + query_vector: QueryVector /** The final number of nearest neighbors to return as top hits */ k: long /** The number of nearest neighbor candidates to consider per shard */ num_candidates: long - /** Boost value to apply to kNN scores */ - boost?: float - /** Filters for the kNN search query */ - filter?: QueryContainer | QueryContainer[] - /** The minimum similarity for a vector to be considered a match */ - similarity?: double } From 246a17a8519d7b45b508ce46ce3fd4340d89f00c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Peter=20Stra=C3=9Fer?= Date: Thu, 21 Sep 2023 07:50:49 +0200 Subject: [PATCH 4/4] changing type of the similarity field to float --- output/schema/schema.json | 2 +- output/typescript/types.ts | 2 +- specification/_types/Knn.ts | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/output/schema/schema.json b/output/schema/schema.json index a79e0798d6..b59c1a2df6 100644 --- a/output/schema/schema.json +++ b/output/schema/schema.json @@ -42778,7 +42778,7 @@ "type": { "kind": "instance_of", "type": { - "name": "double", + "name": "float", "namespace": "_types" } } diff --git a/output/typescript/types.ts b/output/typescript/types.ts index 3023e4a20b..a5525780fc 100644 --- a/output/typescript/types.ts +++ b/output/typescript/types.ts @@ -2339,7 +2339,7 @@ export interface KnnQuery { num_candidates: long boost?: float filter?: QueryDslQueryContainer | QueryDslQueryContainer[] - similarity?: double + similarity?: float } export interface LatLonGeoLocation { diff --git a/specification/_types/Knn.ts b/specification/_types/Knn.ts index 6d8e450941..ea98cad0eb 100644 --- a/specification/_types/Knn.ts +++ b/specification/_types/Knn.ts @@ -39,7 +39,7 @@ export interface KnnQuery { /** Filters for the kNN search query */ filter?: QueryContainer | QueryContainer[] /** The minimum similarity for a vector to be considered a match */ - similarity?: double + similarity?: float } /** @variants container */