From f06bbf52d3ab8a602317dc3cb5e02099ed6b685f Mon Sep 17 00:00:00 2001 From: Quentin Pradet Date: Fri, 3 Oct 2025 14:35:37 +0400 Subject: [PATCH 1/2] Allow hex-encoded byte query vectors --- output/openapi/elasticsearch-openapi.json | 18 ++++++-- .../elasticsearch-serverless-openapi.json | 18 ++++++-- output/schema/schema.json | 41 +++++++++++++------ output/typescript/types.ts | 2 +- specification/_types/Knn.ts | 3 +- 5 files changed, 59 insertions(+), 23 deletions(-) diff --git a/output/openapi/elasticsearch-openapi.json b/output/openapi/elasticsearch-openapi.json index 76b5f3edaa..cceafb8029 100644 --- a/output/openapi/elasticsearch-openapi.json +++ b/output/openapi/elasticsearch-openapi.json @@ -62609,10 +62609,20 @@ ] }, "_types.QueryVector": { - "type": "array", - "items": { - "type": "number" - } + "oneOf": [ + { + "type": "array", + "items": { + "type": "number" + } + }, + { + "type": "array", + "items": { + "type": "string" + } + } + ] }, "_types.QueryVectorBuilder": { "type": "object", diff --git a/output/openapi/elasticsearch-serverless-openapi.json b/output/openapi/elasticsearch-serverless-openapi.json index 95dcc42e0e..c0f0cffb36 100644 --- a/output/openapi/elasticsearch-serverless-openapi.json +++ b/output/openapi/elasticsearch-serverless-openapi.json @@ -38838,10 +38838,20 @@ ] }, "_types.QueryVector": { - "type": "array", - "items": { - "type": "number" - } + "oneOf": [ + { + "type": "array", + "items": { + "type": "number" + } + }, + { + "type": "array", + "items": { + "type": "string" + } + } + ] }, "_types.QueryVectorBuilder": { "type": "object", diff --git a/output/schema/schema.json b/output/schema/schema.json index 49fd2464a2..2002670153 100644 --- a/output/schema/schema.json +++ b/output/schema/schema.json @@ -53968,7 +53968,7 @@ } } ], - "specLocation": "_types/Knn.ts#L64-L87" + "specLocation": "_types/Knn.ts#L65-L88" }, { "kind": "interface", @@ -54227,7 +54227,7 @@ } } ], - "specLocation": "_types/Knn.ts#L35-L62" + "specLocation": "_types/Knn.ts#L36-L63" }, { "kind": "interface", @@ -55690,16 +55690,31 @@ "name": "QueryVector", "namespace": "_types" }, - "specLocation": "_types/Knn.ts#L25-L25", + "specLocation": "_types/Knn.ts#L26-L26", "type": { - "kind": "array_of", - "value": { - "kind": "instance_of", - "type": { - "name": "float", - "namespace": "_types" + "kind": "union_of", + "items": [ + { + "kind": "array_of", + "value": { + "kind": "instance_of", + "type": { + "name": "float", + "namespace": "_types" + } + } + }, + { + "kind": "array_of", + "value": { + "kind": "instance_of", + "type": { + "name": "string", + "namespace": "_builtins" + } + } } - } + ] } }, { @@ -55721,7 +55736,7 @@ } } ], - "specLocation": "_types/Knn.ts#L89-L92", + "specLocation": "_types/Knn.ts#L90-L93", "variants": { "kind": "container" } @@ -56158,7 +56173,7 @@ } } ], - "specLocation": "_types/Knn.ts#L30-L33" + "specLocation": "_types/Knn.ts#L31-L34" }, { "kind": "interface", @@ -58566,7 +58581,7 @@ } } ], - "specLocation": "_types/Knn.ts#L94-L103" + "specLocation": "_types/Knn.ts#L95-L104" }, { "kind": "interface", diff --git a/output/typescript/types.ts b/output/typescript/types.ts index 4e691b87d7..675b918d65 100644 --- a/output/typescript/types.ts +++ b/output/typescript/types.ts @@ -2710,7 +2710,7 @@ export interface QueryCacheStats { total_count: long } -export type QueryVector = float[] +export type QueryVector = float[] | string[] export interface QueryVectorBuilder { text_embedding?: TextEmbedding diff --git a/specification/_types/Knn.ts b/specification/_types/Knn.ts index f5fef4666a..2f67b8f09c 100644 --- a/specification/_types/Knn.ts +++ b/specification/_types/Knn.ts @@ -22,7 +22,8 @@ import { float, integer } from '@_types/Numeric' import { InnerHits } from '@global/search/_types/hits' import { QueryBase, QueryContainer } from './query_dsl/abstractions' -export type QueryVector = float[] +/* Byte vectors can be hex-encoded strings */ +export type QueryVector = float[] | string[] /* KnnSearch (used in kNN search) and KnnQuery (ued in kNN queries) are close * but different enough to require different classes */ From e1afd9120e53a916148aaab850bec05a75fc3fdd Mon Sep 17 00:00:00 2001 From: Quentin Pradet Date: Fri, 3 Oct 2025 14:54:01 +0400 Subject: [PATCH 2/2] Fix string type --- output/openapi/elasticsearch-openapi.json | 5 +---- output/openapi/elasticsearch-serverless-openapi.json | 5 +---- output/schema/schema.json | 11 ++++------- output/typescript/types.ts | 2 +- specification/_types/Knn.ts | 2 +- 5 files changed, 8 insertions(+), 17 deletions(-) diff --git a/output/openapi/elasticsearch-openapi.json b/output/openapi/elasticsearch-openapi.json index cceafb8029..7892259ad8 100644 --- a/output/openapi/elasticsearch-openapi.json +++ b/output/openapi/elasticsearch-openapi.json @@ -62617,10 +62617,7 @@ } }, { - "type": "array", - "items": { - "type": "string" - } + "type": "string" } ] }, diff --git a/output/openapi/elasticsearch-serverless-openapi.json b/output/openapi/elasticsearch-serverless-openapi.json index c0f0cffb36..9fbb82d812 100644 --- a/output/openapi/elasticsearch-serverless-openapi.json +++ b/output/openapi/elasticsearch-serverless-openapi.json @@ -38846,10 +38846,7 @@ } }, { - "type": "array", - "items": { - "type": "string" - } + "type": "string" } ] }, diff --git a/output/schema/schema.json b/output/schema/schema.json index 2002670153..d7c364ac55 100644 --- a/output/schema/schema.json +++ b/output/schema/schema.json @@ -55705,13 +55705,10 @@ } }, { - "kind": "array_of", - "value": { - "kind": "instance_of", - "type": { - "name": "string", - "namespace": "_builtins" - } + "kind": "instance_of", + "type": { + "name": "string", + "namespace": "_builtins" } } ] diff --git a/output/typescript/types.ts b/output/typescript/types.ts index 675b918d65..817f42306f 100644 --- a/output/typescript/types.ts +++ b/output/typescript/types.ts @@ -2710,7 +2710,7 @@ export interface QueryCacheStats { total_count: long } -export type QueryVector = float[] | string[] +export type QueryVector = float[] | string export interface QueryVectorBuilder { text_embedding?: TextEmbedding diff --git a/specification/_types/Knn.ts b/specification/_types/Knn.ts index 2f67b8f09c..bf1bcd03c5 100644 --- a/specification/_types/Knn.ts +++ b/specification/_types/Knn.ts @@ -23,7 +23,7 @@ import { InnerHits } from '@global/search/_types/hits' import { QueryBase, QueryContainer } from './query_dsl/abstractions' /* Byte vectors can be hex-encoded strings */ -export type QueryVector = float[] | string[] +export type QueryVector = float[] | string /* KnnSearch (used in kNN search) and KnnQuery (ued in kNN queries) are close * but different enough to require different classes */