From 6a1243db8cefb7a734bebe6d0f15b3b9ec475dde Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Laurent=20Saint-F=C3=A9lix?= Date: Tue, 20 Feb 2024 15:23:52 +0100 Subject: [PATCH] add inner_hits field to KnnQuery within search (#2422) --- .../elasticsearch-serverless-openapi.json | 3 + output/schema/schema.json | 94 +++++++++++-------- output/typescript/types.ts | 3 +- specification/_doc_ids/table.csv | 1 + specification/_types/Knn.ts | 6 ++ 5 files changed, 66 insertions(+), 41 deletions(-) diff --git a/output/openapi/elasticsearch-serverless-openapi.json b/output/openapi/elasticsearch-serverless-openapi.json index 2e448632e7..2ab23a3f30 100644 --- a/output/openapi/elasticsearch-serverless-openapi.json +++ b/output/openapi/elasticsearch-serverless-openapi.json @@ -39380,6 +39380,9 @@ "similarity": { "description": "The minimum similarity for a vector to be considered a match", "type": "number" + }, + "inner_hits": { + "$ref": "#/components/schemas/_global.search._types:InnerHits" } }, "required": [ diff --git a/output/schema/schema.json b/output/schema/schema.json index 026e50543f..9052a457b4 100644 --- a/output/schema/schema.json +++ b/output/schema/schema.json @@ -43616,9 +43616,23 @@ "namespace": "_types" } } + }, + { + "description": "If defined, each search hit will contain inner hits.", + "docId": "knn-inner-hits", + "docUrl": "https://www.elastic.co/guide/en/elasticsearch/reference/{branch}/knn-search.html#nested-knn-search-inner-hits", + "name": "inner_hits", + "required": false, + "type": { + "kind": "instance_of", + "type": { + "name": "InnerHits", + "namespace": "_global.search._types" + } + } } ], - "specLocation": "_types/Knn.ts#L26-L43" + "specLocation": "_types/Knn.ts#L27-L49" }, { "kind": "interface", @@ -44930,7 +44944,7 @@ "name": "QueryVector", "namespace": "_types" }, - "specLocation": "_types/Knn.ts#L24-L24", + "specLocation": "_types/Knn.ts#L25-L25", "type": { "kind": "array_of", "value": { @@ -44961,7 +44975,7 @@ } } ], - "specLocation": "_types/Knn.ts#L45-L48", + "specLocation": "_types/Knn.ts#L51-L54", "variants": { "kind": "container" } @@ -47208,7 +47222,7 @@ } } ], - "specLocation": "_types/Knn.ts#L50-L53" + "specLocation": "_types/Knn.ts#L56-L59" }, { "kind": "enum", @@ -164272,7 +164286,7 @@ } } ], - "specLocation": "nodes/info/types.ts#L180-L182" + "specLocation": "nodes/info/types.ts#L182-L184" }, { "kind": "interface", @@ -164296,7 +164310,7 @@ } } ], - "specLocation": "nodes/info/types.ts#L231-L233" + "specLocation": "nodes/info/types.ts#L233-L235" }, { "kind": "interface", @@ -164317,7 +164331,7 @@ } } ], - "specLocation": "nodes/info/types.ts#L200-L202" + "specLocation": "nodes/info/types.ts#L202-L204" }, { "kind": "interface", @@ -164338,7 +164352,7 @@ } } ], - "specLocation": "nodes/info/types.ts#L184-L186" + "specLocation": "nodes/info/types.ts#L186-L188" }, { "attachedBehaviors": [ @@ -164410,7 +164424,7 @@ } } ], - "specLocation": "nodes/info/types.ts#L174-L178" + "specLocation": "nodes/info/types.ts#L174-L180" }, { "kind": "interface", @@ -164467,7 +164481,7 @@ } } ], - "specLocation": "nodes/info/types.ts#L302-L307" + "specLocation": "nodes/info/types.ts#L304-L309" }, { "kind": "interface", @@ -164491,7 +164505,7 @@ } } ], - "specLocation": "nodes/info/types.ts#L223-L225" + "specLocation": "nodes/info/types.ts#L225-L227" }, { "kind": "interface", @@ -164554,7 +164568,7 @@ } } ], - "specLocation": "nodes/info/types.ts#L227-L229" + "specLocation": "nodes/info/types.ts#L229-L231" }, { "kind": "interface", @@ -164674,7 +164688,7 @@ } } ], - "specLocation": "nodes/info/types.ts#L309-L320" + "specLocation": "nodes/info/types.ts#L311-L322" }, { "kind": "interface", @@ -164706,7 +164720,7 @@ } } ], - "specLocation": "nodes/info/types.ts#L322-L325" + "specLocation": "nodes/info/types.ts#L324-L327" }, { "kind": "interface", @@ -164738,7 +164752,7 @@ } } ], - "specLocation": "nodes/info/types.ts#L327-L330" + "specLocation": "nodes/info/types.ts#L329-L332" }, { "kind": "interface", @@ -164781,7 +164795,7 @@ } } ], - "specLocation": "nodes/info/types.ts#L332-L336" + "specLocation": "nodes/info/types.ts#L334-L338" }, { "kind": "interface", @@ -164879,7 +164893,7 @@ } } ], - "specLocation": "nodes/info/types.ts#L338-L347" + "specLocation": "nodes/info/types.ts#L340-L349" }, { "kind": "interface", @@ -165013,7 +165027,7 @@ } } ], - "specLocation": "nodes/info/types.ts#L280-L283" + "specLocation": "nodes/info/types.ts#L282-L285" }, { "kind": "interface", @@ -165034,7 +165048,7 @@ } } ], - "specLocation": "nodes/info/types.ts#L285-L287" + "specLocation": "nodes/info/types.ts#L287-L289" }, { "kind": "interface", @@ -165055,7 +165069,7 @@ } } ], - "specLocation": "nodes/info/types.ts#L289-L291" + "specLocation": "nodes/info/types.ts#L291-L293" }, { "kind": "interface", @@ -165404,7 +165418,7 @@ } } ], - "specLocation": "nodes/info/types.ts#L188-L193" + "specLocation": "nodes/info/types.ts#L190-L195" }, { "kind": "interface", @@ -165426,7 +165440,7 @@ } ], "shortcutProperty": "default", - "specLocation": "nodes/info/types.ts#L195-L198" + "specLocation": "nodes/info/types.ts#L197-L200" }, { "kind": "interface", @@ -165831,7 +165845,7 @@ } } ], - "specLocation": "nodes/info/types.ts#L219-L221" + "specLocation": "nodes/info/types.ts#L221-L223" }, { "kind": "interface", @@ -165924,7 +165938,7 @@ } } ], - "specLocation": "nodes/info/types.ts#L204-L208" + "specLocation": "nodes/info/types.ts#L206-L210" }, { "kind": "interface", @@ -165945,7 +165959,7 @@ } } ], - "specLocation": "nodes/info/types.ts#L215-L217" + "specLocation": "nodes/info/types.ts#L217-L219" }, { "kind": "interface", @@ -165967,7 +165981,7 @@ } ], "shortcutProperty": "default", - "specLocation": "nodes/info/types.ts#L210-L213" + "specLocation": "nodes/info/types.ts#L212-L215" }, { "kind": "interface", @@ -166024,7 +166038,7 @@ } } ], - "specLocation": "nodes/info/types.ts#L349-L353" + "specLocation": "nodes/info/types.ts#L351-L355" }, { "kind": "interface", @@ -166074,7 +166088,7 @@ } } ], - "specLocation": "nodes/info/types.ts#L235-L239" + "specLocation": "nodes/info/types.ts#L237-L241" }, { "kind": "interface", @@ -166095,7 +166109,7 @@ } } ], - "specLocation": "nodes/info/types.ts#L272-L274" + "specLocation": "nodes/info/types.ts#L274-L276" }, { "kind": "interface", @@ -166116,7 +166130,7 @@ } } ], - "specLocation": "nodes/info/types.ts#L276-L278" + "specLocation": "nodes/info/types.ts#L278-L280" }, { "kind": "interface", @@ -166170,7 +166184,7 @@ } } ], - "specLocation": "nodes/info/types.ts#L241-L246" + "specLocation": "nodes/info/types.ts#L243-L248" }, { "kind": "interface", @@ -166202,7 +166216,7 @@ } } ], - "specLocation": "nodes/info/types.ts#L252-L255" + "specLocation": "nodes/info/types.ts#L254-L257" }, { "kind": "interface", @@ -166278,7 +166292,7 @@ } } ], - "specLocation": "nodes/info/types.ts#L257-L261" + "specLocation": "nodes/info/types.ts#L259-L263" }, { "kind": "interface", @@ -166310,7 +166324,7 @@ } } ], - "specLocation": "nodes/info/types.ts#L267-L270" + "specLocation": "nodes/info/types.ts#L269-L272" }, { "kind": "interface", @@ -166331,7 +166345,7 @@ } } ], - "specLocation": "nodes/info/types.ts#L263-L265" + "specLocation": "nodes/info/types.ts#L265-L267" }, { "kind": "interface", @@ -166363,7 +166377,7 @@ } } ], - "specLocation": "nodes/info/types.ts#L248-L250" + "specLocation": "nodes/info/types.ts#L250-L252" }, { "kind": "interface", @@ -166538,7 +166552,7 @@ } } ], - "specLocation": "nodes/info/types.ts#L355-L369" + "specLocation": "nodes/info/types.ts#L357-L371" }, { "kind": "interface", @@ -166673,7 +166687,7 @@ } } ], - "specLocation": "nodes/info/types.ts#L371-L388" + "specLocation": "nodes/info/types.ts#L373-L390" }, { "kind": "interface", @@ -166728,7 +166742,7 @@ } } ], - "specLocation": "nodes/info/types.ts#L390-L397" + "specLocation": "nodes/info/types.ts#L392-L399" }, { "kind": "interface", @@ -166804,7 +166818,7 @@ } } ], - "specLocation": "nodes/info/types.ts#L293-L300" + "specLocation": "nodes/info/types.ts#L295-L302" }, { "attachedBehaviors": [ diff --git a/output/typescript/types.ts b/output/typescript/types.ts index be0f08213e..723ef2f6b3 100644 --- a/output/typescript/types.ts +++ b/output/typescript/types.ts @@ -2346,6 +2346,7 @@ export interface KnnQuery { boost?: float filter?: QueryDslQueryContainer | QueryDslQueryContainer[] similarity?: float + inner_hits?: SearchInnerHits } export interface LatLonGeoLocation { @@ -2471,7 +2472,7 @@ export interface QueryCacheStats { memory_size?: ByteSize memory_size_in_bytes: long miss_count: integer - total_count: long + total_count: integer } export type QueryVector = float[] diff --git a/specification/_doc_ids/table.csv b/specification/_doc_ids/table.csv index fbfa353c2a..85daf3063d 100644 --- a/specification/_doc_ids/table.csv +++ b/specification/_doc_ids/table.csv @@ -219,6 +219,7 @@ json-processor,https://www.elastic.co/guide/en/elasticsearch/reference/{branch}/ k-precision,https://www.elastic.co/guide/en/elasticsearch/reference/{branch}/search-rank-eval.html#k-precision k-recall,https://www.elastic.co/guide/en/elasticsearch/reference/{branch}/search-rank-eval.html#k-recall kv-processor,https://www.elastic.co/guide/en/elasticsearch/reference/{branch}/kv-processor.html +knn-inner-hits,https://www.elastic.co/guide/en/elasticsearch/reference/{branch}/knn-search.html#nested-knn-search-inner-hits logstash-api-delete-pipeline,https://www.elastic.co/guide/en/elasticsearch/reference/{branch}/logstash-api-delete-pipeline.html logstash-api-get-pipeline,https://www.elastic.co/guide/en/elasticsearch/reference/{branch}/logstash-api-get-pipeline.html logstash-api-put-pipeline,https://www.elastic.co/guide/en/elasticsearch/reference/{branch}/logstash-api-put-pipeline.html diff --git a/specification/_types/Knn.ts b/specification/_types/Knn.ts index 3ac82a11ed..7702eece37 100644 --- a/specification/_types/Knn.ts +++ b/specification/_types/Knn.ts @@ -20,6 +20,7 @@ import { Field } from '@_types/common' import { long, float } from '@_types/Numeric' import { QueryContainer } from './query_dsl/abstractions' +import { InnerHits } from '@global/search/_types/hits' export type QueryVector = float[] @@ -40,6 +41,11 @@ export interface KnnQuery { filter?: QueryContainer | QueryContainer[] /** The minimum similarity for a vector to be considered a match */ similarity?: float + /** + * If defined, each search hit will contain inner hits. + * @doc_id knn-inner-hits + */ + inner_hits?: InnerHits } /** @variants container */