From 72aa8bbeb299336f55e9c282905660389d389d9e Mon Sep 17 00:00:00 2001 From: Quentin Pradet Date: Mon, 14 Apr 2025 19:53:35 +0400 Subject: [PATCH] Remove knn_search API (#4276) As it was only ever experimental and then deprecated, it isn't supported in 9.0, and only works with `compatible-with=8` is set. (cherry picked from commit 2a24e33865256e85eaa8e2de9e793646f147c4df) # Conflicts: # output/schema/schema.json --- output/openapi/elasticsearch-openapi.json | 190 ---------- output/schema/schema.json | 343 +----------------- output/typescript/types.ts | 29 -- package-lock.json | 42 +-- package.json | 2 +- .../_global/knn_search/KnnSearchRequest.ts | 112 ------ .../_global/knn_search/KnnSearchResponse.ts | 54 --- .../_global/knn_search/_types/Knn.ts | 33 -- 8 files changed, 28 insertions(+), 777 deletions(-) delete mode 100644 specification/_global/knn_search/KnnSearchRequest.ts delete mode 100644 specification/_global/knn_search/KnnSearchResponse.ts delete mode 100644 specification/_global/knn_search/_types/Knn.ts diff --git a/output/openapi/elasticsearch-openapi.json b/output/openapi/elasticsearch-openapi.json index 1e00084b14..8b6c4d866f 100644 --- a/output/openapi/elasticsearch-openapi.json +++ b/output/openapi/elasticsearch-openapi.json @@ -20333,60 +20333,6 @@ "x-state": "Added in 5.0.0" } }, - "/{index}/_knn_search": { - "get": { - "tags": [ - "search" - ], - "summary": "Run a knn search", - "description": "NOTE: The kNN search API has been replaced by the `knn` option in the search API.\n\nPerform a k-nearest neighbor (kNN) search on a dense_vector field and return the matching documents.\nGiven a query vector, the API finds the k closest vectors and returns those documents as search hits.\n\nElasticsearch uses the HNSW algorithm to support efficient kNN search.\nLike most kNN algorithms, HNSW is an approximate method that sacrifices result accuracy for improved search speed.\nThis means the results returned are not always the true k closest neighbors.\n\nThe kNN search API supports restricting the search using a filter.\nThe search will return the top k documents that also match the filter query.\n\nA kNN search response has the exact same structure as a search API response.\nHowever, certain sections have a meaning specific to kNN search:\n\n* The document `_score` is determined by the similarity between the query and document vector.\n* The `hits.total` object contains the total number of nearest neighbor candidates considered, which is `num_candidates * num_shards`. The `hits.total.relation` will always be `eq`, indicating an exact value.", - "operationId": "knn-search", - "parameters": [ - { - "$ref": "#/components/parameters/knn_search-index" - }, - { - "$ref": "#/components/parameters/knn_search-routing" - } - ], - "requestBody": { - "$ref": "#/components/requestBodies/knn_search" - }, - "responses": { - "200": { - "$ref": "#/components/responses/knn_search-200" - } - }, - "deprecated": true, - "x-state": "Technical preview" - }, - "post": { - "tags": [ - "search" - ], - "summary": "Run a knn search", - "description": "NOTE: The kNN search API has been replaced by the `knn` option in the search API.\n\nPerform a k-nearest neighbor (kNN) search on a dense_vector field and return the matching documents.\nGiven a query vector, the API finds the k closest vectors and returns those documents as search hits.\n\nElasticsearch uses the HNSW algorithm to support efficient kNN search.\nLike most kNN algorithms, HNSW is an approximate method that sacrifices result accuracy for improved search speed.\nThis means the results returned are not always the true k closest neighbors.\n\nThe kNN search API supports restricting the search using a filter.\nThe search will return the top k documents that also match the filter query.\n\nA kNN search response has the exact same structure as a search API response.\nHowever, certain sections have a meaning specific to kNN search:\n\n* The document `_score` is determined by the similarity between the query and document vector.\n* The `hits.total` object contains the total number of nearest neighbor candidates considered, which is `num_candidates * num_shards`. The `hits.total.relation` will always be `eq`, indicating an exact value.", - "operationId": "knn-search-1", - "parameters": [ - { - "$ref": "#/components/parameters/knn_search-index" - }, - { - "$ref": "#/components/parameters/knn_search-routing" - } - ], - "requestBody": { - "$ref": "#/components/requestBodies/knn_search" - }, - "responses": { - "200": { - "$ref": "#/components/responses/knn_search-200" - } - }, - "deprecated": true, - "x-state": "Technical preview" - } - }, "/_license": { "get": { "tags": [ @@ -82148,31 +82094,6 @@ "throttled" ] }, - "_global.knn_search._types.Query": { - "type": "object", - "properties": { - "field": { - "$ref": "#/components/schemas/_types.Field" - }, - "query_vector": { - "$ref": "#/components/schemas/_types.QueryVector" - }, - "k": { - "description": "The final number of nearest neighbors to return as top hits", - "type": "number" - }, - "num_candidates": { - "description": "The number of nearest neighbor candidates to consider per shard", - "type": "number" - } - }, - "required": [ - "field", - "query_vector", - "k", - "num_candidates" - ] - }, "license.get.LicenseInformation": { "type": "object", "properties": { @@ -102052,49 +101973,6 @@ } } }, - "knn_search-200": { - "description": "", - "content": { - "application/json": { - "schema": { - "type": "object", - "properties": { - "took": { - "description": "The milliseconds it took Elasticsearch to run the request.", - "type": "number" - }, - "timed_out": { - "description": "If true, the request timed out before completion;\nreturned results may be partial or empty.", - "type": "boolean" - }, - "_shards": { - "$ref": "#/components/schemas/_types.ShardStatistics" - }, - "hits": { - "$ref": "#/components/schemas/_global.search._types.HitsMetadata" - }, - "fields": { - "description": "The field values for the documents. These fields\nmust be specified in the request using the `fields` parameter.", - "type": "object", - "additionalProperties": { - "type": "object" - } - }, - "max_score": { - "description": "The highest returned document score. This value is null for requests\nthat do not sort by score.", - "type": "number" - } - }, - "required": [ - "took", - "timed_out", - "_shards", - "hits" - ] - } - } - } - }, "license.post-200": { "description": "", "content": { @@ -110386,27 +110264,6 @@ }, "style": "form" }, - "knn_search-index": { - "in": "path", - "name": "index", - "description": "A comma-separated list of index names to search;\nuse `_all` or to perform the operation on all indices.", - "required": true, - "deprecated": false, - "schema": { - "$ref": "#/components/schemas/_types.Indices" - }, - "style": "simple" - }, - "knn_search-routing": { - "in": "query", - "name": "routing", - "description": "A comma-separated list of specific routing values.", - "deprecated": false, - "schema": { - "$ref": "#/components/schemas/_types.Routing" - }, - "style": "form" - }, "license.post-acknowledge": { "in": "query", "name": "acknowledge", @@ -116095,53 +115952,6 @@ }, "required": true }, - "knn_search": { - "content": { - "application/json": { - "schema": { - "type": "object", - "properties": { - "_source": { - "$ref": "#/components/schemas/_global.search._types.SourceConfig" - }, - "docvalue_fields": { - "description": "The request returns doc values for field names matching these patterns\nin the `hits.fields` property of the response.\nIt accepts wildcard (`*`) patterns.", - "type": "array", - "items": { - "$ref": "#/components/schemas/_types.query_dsl.FieldAndFormat" - } - }, - "stored_fields": { - "$ref": "#/components/schemas/_types.Fields" - }, - "fields": { - "$ref": "#/components/schemas/_types.Fields" - }, - "filter": { - "description": "A query to filter the documents that can match. The kNN search will return the top\n`k` documents that also match this filter. The value can be a single query or a\nlist of queries. If `filter` isn't provided, all documents are allowed to match.", - "oneOf": [ - { - "$ref": "#/components/schemas/_types.query_dsl.QueryContainer" - }, - { - "type": "array", - "items": { - "$ref": "#/components/schemas/_types.query_dsl.QueryContainer" - } - } - ] - }, - "knn": { - "$ref": "#/components/schemas/_global.knn_search._types.Query" - } - }, - "required": [ - "knn" - ] - } - } - } - }, "license.post": { "content": { "application/json": { diff --git a/output/schema/schema.json b/output/schema/schema.json index d15d6e3a4b..f483b3696f 100644 --- a/output/schema/schema.json +++ b/output/schema/schema.json @@ -10784,31 +10784,19 @@ { "availability": { "stack": { - "since": "8.0.0", - "stability": "experimental" + "stability": "experimental", + "visibility": "public" } }, - "deprecation": { - "description": "The kNN search API has been replaced by the `knn` option in the search API.", - "version": "8.4.0" - }, - "description": "Run a knn search.\n\nNOTE: The kNN search API has been replaced by the `knn` option in the search API.\n\nPerform a k-nearest neighbor (kNN) search on a dense_vector field and return the matching documents.\nGiven a query vector, the API finds the k closest vectors and returns those documents as search hits.\n\nElasticsearch uses the HNSW algorithm to support efficient kNN search.\nLike most kNN algorithms, HNSW is an approximate method that sacrifices result accuracy for improved search speed.\nThis means the results returned are not always the true k closest neighbors.\n\nThe kNN search API supports restricting the search using a filter.\nThe search will return the top k documents that also match the filter query.\n\nA kNN search response has the exact same structure as a search API response.\nHowever, certain sections have a meaning specific to kNN search:\n\n* The document `_score` is determined by the similarity between the query and document vector.\n* The `hits.total` object contains the total number of nearest neighbor candidates considered, which is `num_candidates * num_shards`. The `hits.total.relation` will always be `eq`, indicating an exact value.", - "docId": "search-knn", - "docTag": "search", - "docUrl": "https://www.elastic.co/docs/api/doc/elasticsearch/v9/operation/operation-knn-search", + "description": "Performs a kNN search.", + "docUrl": "https://www.elastic.co/guide/en/elasticsearch/reference/master/search-search.html", "name": "knn_search", - "request": { - "name": "Request", - "namespace": "_global.knn_search" - }, + "request": null, "requestBodyRequired": false, "requestMediaType": [ "application/json" ], - "response": { - "name": "Response", - "namespace": "_global.knn_search" - }, + "response": null, "responseMediaType": [ "application/json" ], @@ -30335,325 +30323,6 @@ }, "specLocation": "_global/info/RootNodeInfoResponse.ts#L23-L40" }, - { - "kind": "request", - "attachedBehaviors": [ - "CommonQueryParameters" - ], - "body": { - "kind": "properties", - "properties": [ - { - "description": "Indicates which source fields are returned for matching documents. These\nfields are returned in the `hits._source` property of the search response.", - "name": "_source", - "required": false, - "serverDefault": "true", - "type": { - "kind": "instance_of", - "type": { - "name": "SourceConfig", - "namespace": "_global.search._types" - } - } - }, - { - "description": "The request returns doc values for field names matching these patterns\nin the `hits.fields` property of the response.\nIt accepts wildcard (`*`) patterns.", - "name": "docvalue_fields", - "required": false, - "type": { - "kind": "array_of", - "value": { - "kind": "instance_of", - "type": { - "name": "FieldAndFormat", - "namespace": "_types.query_dsl" - } - } - } - }, - { - "description": "A list of stored fields to return as part of a hit. If no fields are specified,\nno stored fields are included in the response. If this field is specified, the `_source`\nparameter defaults to `false`. You can pass `_source: true` to return both source fields\nand stored fields in the search response.", - "name": "stored_fields", - "required": false, - "type": { - "kind": "instance_of", - "type": { - "name": "Fields", - "namespace": "_types" - } - } - }, - { - "description": "The request returns values for field names matching these patterns\nin the `hits.fields` property of the response.\nIt accepts wildcard (`*`) patterns.", - "name": "fields", - "required": false, - "type": { - "kind": "instance_of", - "type": { - "name": "Fields", - "namespace": "_types" - } - } - }, - { - "availability": { - "serverless": {}, - "stack": { - "since": "8.2.0" - } - }, - "description": "A query to filter the documents that can match. The kNN search will return the top\n`k` documents that also match this filter. The value can be a single query or a\nlist of queries. If `filter` isn't provided, all documents are allowed to match.", - "name": "filter", - "required": false, - "type": { - "kind": "union_of", - "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" - } - } - } - ] - } - }, - { - "description": "The kNN query to run.", - "extDocId": "query-dsl-knn-query", - "extDocUrl": "https://www.elastic.co/docs/reference/query-languages/query-dsl/query-dsl-knn-query", - "name": "knn", - "required": true, - "type": { - "kind": "instance_of", - "type": { - "name": "Query", - "namespace": "_global.knn_search._types" - } - } - } - ] - }, - "deprecation": { - "description": "The kNN search API has been replaced by the `knn` option in the search API.", - "version": "8.4.0" - }, - "description": "Run a knn search.\n\nNOTE: The kNN search API has been replaced by the `knn` option in the search API.\n\nPerform a k-nearest neighbor (kNN) search on a dense_vector field and return the matching documents.\nGiven a query vector, the API finds the k closest vectors and returns those documents as search hits.\n\nElasticsearch uses the HNSW algorithm to support efficient kNN search.\nLike most kNN algorithms, HNSW is an approximate method that sacrifices result accuracy for improved search speed.\nThis means the results returned are not always the true k closest neighbors.\n\nThe kNN search API supports restricting the search using a filter.\nThe search will return the top k documents that also match the filter query.\n\nA kNN search response has the exact same structure as a search API response.\nHowever, certain sections have a meaning specific to kNN search:\n\n* The document `_score` is determined by the similarity between the query and document vector.\n* The `hits.total` object contains the total number of nearest neighbor candidates considered, which is `num_candidates * num_shards`. The `hits.total.relation` will always be `eq`, indicating an exact value.", - "inherits": { - "type": { - "name": "RequestBase", - "namespace": "_types" - } - }, - "name": { - "name": "Request", - "namespace": "_global.knn_search" - }, - "path": [ - { - "description": "A comma-separated list of index names to search;\nuse `_all` or to perform the operation on all indices.", - "name": "index", - "required": true, - "type": { - "kind": "instance_of", - "type": { - "name": "Indices", - "namespace": "_types" - } - } - } - ], - "query": [ - { - "description": "A comma-separated list of specific routing values.", - "name": "routing", - "required": false, - "type": { - "kind": "instance_of", - "type": { - "name": "Routing", - "namespace": "_types" - } - } - } - ], - "specLocation": "_global/knn_search/KnnSearchRequest.ts#L26-L112" - }, - { - "kind": "response", - "body": { - "kind": "properties", - "properties": [ - { - "description": "The milliseconds it took Elasticsearch to run the request.", - "name": "took", - "required": true, - "type": { - "kind": "instance_of", - "type": { - "name": "long", - "namespace": "_types" - } - } - }, - { - "description": "If true, the request timed out before completion;\nreturned results may be partial or empty.", - "name": "timed_out", - "required": true, - "type": { - "kind": "instance_of", - "type": { - "name": "boolean", - "namespace": "_builtins" - } - } - }, - { - "description": "A count of shards used for the request.", - "name": "_shards", - "required": true, - "type": { - "kind": "instance_of", - "type": { - "name": "ShardStatistics", - "namespace": "_types" - } - } - }, - { - "description": "The returned documents and metadata.", - "name": "hits", - "required": true, - "type": { - "kind": "instance_of", - "generics": [ - { - "kind": "instance_of", - "type": { - "name": "TDocument", - "namespace": "_global.knn_search.Response" - } - } - ], - "type": { - "name": "HitsMetadata", - "namespace": "_global.search._types" - } - } - }, - { - "description": "The field values for the documents. These fields\nmust be specified in the request using the `fields` parameter.", - "name": "fields", - "required": false, - "type": { - "kind": "dictionary_of", - "key": { - "kind": "instance_of", - "type": { - "name": "string", - "namespace": "_builtins" - } - }, - "singleKey": false, - "value": { - "kind": "user_defined_value" - } - } - }, - { - "description": "The highest returned document score. This value is null for requests\nthat do not sort by score.", - "name": "max_score", - "required": false, - "type": { - "kind": "instance_of", - "type": { - "name": "double", - "namespace": "_types" - } - } - } - ] - }, - "generics": [ - { - "name": "TDocument", - "namespace": "_global.knn_search.Response" - } - ], - "name": { - "name": "Response", - "namespace": "_global.knn_search" - }, - "specLocation": "_global/knn_search/KnnSearchResponse.ts#L26-L54" - }, - { - "kind": "interface", - "name": { - "name": "Query", - "namespace": "_global.knn_search._types" - }, - "properties": [ - { - "description": "The name of the vector field to search against", - "name": "field", - "required": true, - "type": { - "kind": "instance_of", - "type": { - "name": "Field", - "namespace": "_types" - } - } - }, - { - "description": "The query vector", - "name": "query_vector", - "required": true, - "type": { - "kind": "instance_of", - "type": { - "name": "QueryVector", - "namespace": "_types" - } - } - }, - { - "description": "The final number of nearest neighbors to return as top hits", - "name": "k", - "required": true, - "type": { - "kind": "instance_of", - "type": { - "name": "integer", - "namespace": "_types" - } - } - }, - { - "description": "The number of nearest neighbor candidates to consider per shard", - "name": "num_candidates", - "required": true, - "type": { - "kind": "instance_of", - "type": { - "name": "integer", - "namespace": "_types" - } - } - } - ], - "specLocation": "_global/knn_search/_types/Knn.ts#L24-L33" - }, { "kind": "interface", "name": { diff --git a/output/typescript/types.ts b/output/typescript/types.ts index b78dc4c5fb..6f654d17d5 100644 --- a/output/typescript/types.ts +++ b/output/typescript/types.ts @@ -689,35 +689,6 @@ export interface InfoResponse { version: ElasticsearchVersionInfo } -export interface KnnSearchRequest extends RequestBase { - index: Indices - routing?: Routing - body?: { - _source?: SearchSourceConfig - docvalue_fields?: (QueryDslFieldAndFormat | Field)[] - stored_fields?: Fields - fields?: Fields - filter?: QueryDslQueryContainer | QueryDslQueryContainer[] - knn: KnnSearchQuery - } -} - -export interface KnnSearchResponse { - took: long - timed_out: boolean - _shards: ShardStatistics - hits: SearchHitsMetadata - fields?: Record - max_score?: double -} - -export interface KnnSearchQuery { - field: Field - query_vector: QueryVector - k: integer - num_candidates: integer -} - export interface MgetMultiGetError { error: ErrorCause _id: Id diff --git a/package-lock.json b/package-lock.json index 7f487105e4..15b466151b 100644 --- a/package-lock.json +++ b/package-lock.json @@ -5,7 +5,7 @@ "packages": { "": { "dependencies": { - "@redocly/cli": "^1.34.1", + "@redocly/cli": "^1.34.2", "@stoplight/spectral-cli": "^6.14.2" } }, @@ -486,9 +486,9 @@ } }, "node_modules/@redocly/cli": { - "version": "1.34.1", - "resolved": "https://registry.npmjs.org/@redocly/cli/-/cli-1.34.1.tgz", - "integrity": "sha512-12aTw7A/0n+8T7yKM1E8qlFRFPZnm2i1me0sZ1WOAiGT4I2j4iUcCp+93B0nrjIs1ZdNmrT0TTrMYLhsMJYjaQ==", + "version": "1.34.2", + "resolved": "https://registry.npmjs.org/@redocly/cli/-/cli-1.34.2.tgz", + "integrity": "sha512-XnKG7yrr0GUZ7MyqHk9hRt//HGUSnLDwwEXI8HDQdyDFp+YFbddqcQPOWc/sDeDBTEiBXqwPOb3/VKA+8NtSMw==", "license": "MIT", "dependencies": { "@opentelemetry/api": "1.9.0", @@ -497,8 +497,8 @@ "@opentelemetry/sdk-trace-node": "1.26.0", "@opentelemetry/semantic-conventions": "1.27.0", "@redocly/config": "^0.22.0", - "@redocly/openapi-core": "1.34.1", - "@redocly/respect-core": "1.34.1", + "@redocly/openapi-core": "1.34.2", + "@redocly/respect-core": "1.34.2", "abort-controller": "^3.0.0", "chokidar": "^3.5.1", "colorette": "^1.2.0", @@ -561,9 +561,9 @@ "license": "MIT" }, "node_modules/@redocly/openapi-core": { - "version": "1.34.1", - "resolved": "https://registry.npmjs.org/@redocly/openapi-core/-/openapi-core-1.34.1.tgz", - "integrity": "sha512-KI1QOGvDk6oREbTu0JORxZX1NBxraXUbXczv0LYDs9EPp06coq874hQORqSHGEUV/DX2A6gjv4Ax33g/LFJBww==", + "version": "1.34.2", + "resolved": "https://registry.npmjs.org/@redocly/openapi-core/-/openapi-core-1.34.2.tgz", + "integrity": "sha512-glfkQFJizLdq2fBkNvc2FJW0sxDb5exd0wIXhFk+WHaFLMREBC3CxRo2Zq7uJIdfV9U3YTceMbXJklpDfmmwFQ==", "license": "MIT", "dependencies": { "@redocly/ajv": "^8.11.2", @@ -603,14 +603,14 @@ } }, "node_modules/@redocly/respect-core": { - "version": "1.34.1", - "resolved": "https://registry.npmjs.org/@redocly/respect-core/-/respect-core-1.34.1.tgz", - "integrity": "sha512-Lzea25WqwxVK5+aCiq/pr7lUFdsZPYSqNzl05Z4jEtuP1DEIxJNG31ID75dZt30pPtyxjaa/dBuccruYlYflzw==", + "version": "1.34.2", + "resolved": "https://registry.npmjs.org/@redocly/respect-core/-/respect-core-1.34.2.tgz", + "integrity": "sha512-X6VR9bbHXrI01Wh5t6TIHxFCVHcP4Iy42micKLIk/Cg6EmHVbaSDGOD6mxChXtEIrwnY+bqyUbjlXr9+YM7B9A==", "license": "MIT", "dependencies": { "@faker-js/faker": "^7.6.0", "@redocly/ajv": "8.11.2", - "@redocly/openapi-core": "1.34.1", + "@redocly/openapi-core": "1.34.2", "better-ajv-errors": "^1.2.0", "colorette": "^2.0.20", "concat-stream": "^2.0.0", @@ -833,9 +833,9 @@ } }, "node_modules/@stoplight/spectral-core": { - "version": "1.19.4", - "resolved": "https://registry.npmjs.org/@stoplight/spectral-core/-/spectral-core-1.19.4.tgz", - "integrity": "sha512-8hnZXfssTlV99SKo8J8BwMt5LsiBFHkCh0V3P7j8IPcCNl//bpG92U4TpYy7AwmUms/zCLX7sxNQC6AZ+bkfzg==", + "version": "1.19.5", + "resolved": "https://registry.npmjs.org/@stoplight/spectral-core/-/spectral-core-1.19.5.tgz", + "integrity": "sha512-i+njdliW7bAHGsHEgDvH0To/9IxiYiBELltkZ7ASVy4i+WXtZ40lQXpeRQRwePrBcSgQl0gcZFuKX10nmSHtbw==", "license": "Apache-2.0", "dependencies": { "@stoplight/better-ajv-errors": "1.0.3", @@ -849,9 +849,9 @@ "@types/json-schema": "^7.0.11", "ajv": "^8.17.1", "ajv-errors": "~3.0.0", - "ajv-formats": "~2.1.0", + "ajv-formats": "~2.1.1", "es-aggregate-error": "^1.0.7", - "jsonpath-plus": "10.2.0", + "jsonpath-plus": "^10.3.0", "lodash": "~4.17.21", "lodash.topath": "^4.5.2", "minimatch": "3.1.2", @@ -2983,9 +2983,9 @@ } }, "node_modules/jsonpath-plus": { - "version": "10.2.0", - "resolved": "https://registry.npmjs.org/jsonpath-plus/-/jsonpath-plus-10.2.0.tgz", - "integrity": "sha512-T9V+8iNYKFL2n2rF+w02LBOT2JjDnTjioaNFrxRy0Bv1y/hNsqR/EBK7Ojy2ythRHwmz2cRIls+9JitQGZC/sw==", + "version": "10.3.0", + "resolved": "https://registry.npmjs.org/jsonpath-plus/-/jsonpath-plus-10.3.0.tgz", + "integrity": "sha512-8TNmfeTCk2Le33A3vRRwtuworG/L5RrgMvdjhKZxvyShO+mBu2fP50OWUjRLNtvw344DdDarFh9buFAZs5ujeA==", "license": "MIT", "dependencies": { "@jsep-plugin/assignment": "^1.3.0", diff --git a/package.json b/package.json index 65aafaa259..9658090436 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "dependencies": { - "@redocly/cli": "^1.34.1", + "@redocly/cli": "^1.34.2", "@stoplight/spectral-cli": "^6.14.2" } } diff --git a/specification/_global/knn_search/KnnSearchRequest.ts b/specification/_global/knn_search/KnnSearchRequest.ts deleted file mode 100644 index 8e62a733de..0000000000 --- a/specification/_global/knn_search/KnnSearchRequest.ts +++ /dev/null @@ -1,112 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -import { SourceConfig } from '@global/search/_types/SourceFilter' -import { RequestBase } from '@_types/Base' -import { Fields, Indices, Routing } from '@_types/common' -import { FieldAndFormat, QueryContainer } from '@_types/query_dsl/abstractions' -import { Query } from './_types/Knn' - -/** - * Run a knn search. - * - * NOTE: The kNN search API has been replaced by the `knn` option in the search API. - * - * Perform a k-nearest neighbor (kNN) search on a dense_vector field and return the matching documents. - * Given a query vector, the API finds the k closest vectors and returns those documents as search hits. - * - * Elasticsearch uses the HNSW algorithm to support efficient kNN search. - * Like most kNN algorithms, HNSW is an approximate method that sacrifices result accuracy for improved search speed. - * This means the results returned are not always the true k closest neighbors. - * - * The kNN search API supports restricting the search using a filter. - * The search will return the top k documents that also match the filter query. - * - * A kNN search response has the exact same structure as a search API response. - * However, certain sections have a meaning specific to kNN search: - * - * * The document `_score` is determined by the similarity between the query and document vector. - * * The `hits.total` object contains the total number of nearest neighbor candidates considered, which is `num_candidates * num_shards`. The `hits.total.relation` will always be `eq`, indicating an exact value. - * @rest_spec_name knn_search - * @availability stack since=8.0.0 stability=experimental - * @deprecated 8.4.0 The kNN search API has been replaced by the `knn` option in the search API. - * @doc_tag search - * @doc_id search-knn - */ -export interface Request extends RequestBase { - urls: [ - { - path: '/{index}/_knn_search' - methods: ['GET', 'POST'] - } - ] - path_parts: { - /** - * A comma-separated list of index names to search; - * use `_all` or to perform the operation on all indices. - */ - index: Indices - } - query_parameters: { - /** - * A comma-separated list of specific routing values. - */ - routing?: Routing - } - body: { - /** - * Indicates which source fields are returned for matching documents. These - * fields are returned in the `hits._source` property of the search response. - * @server_default true - */ - _source?: SourceConfig - /** - * The request returns doc values for field names matching these patterns - * in the `hits.fields` property of the response. - * It accepts wildcard (`*`) patterns. - */ - docvalue_fields?: FieldAndFormat[] - /** - * A list of stored fields to return as part of a hit. If no fields are specified, - * no stored fields are included in the response. If this field is specified, the `_source` - * parameter defaults to `false`. You can pass `_source: true` to return both source fields - * and stored fields in the search response. - */ - stored_fields?: Fields - /** - * The request returns values for field names matching these patterns - * in the `hits.fields` property of the response. - * It accepts wildcard (`*`) patterns. - */ - fields?: Fields - /** - * A query to filter the documents that can match. The kNN search will return the top - * `k` documents that also match this filter. The value can be a single query or a - * list of queries. If `filter` isn't provided, all documents are allowed to match. - * @availability stack since=8.2.0 - * @availability serverless - */ - filter?: QueryContainer | QueryContainer[] - /** - * The kNN query to run. - * @ext_doc_id query-dsl-knn-query - */ - knn: Query - } -} diff --git a/specification/_global/knn_search/KnnSearchResponse.ts b/specification/_global/knn_search/KnnSearchResponse.ts deleted file mode 100644 index a6f4357800..0000000000 --- a/specification/_global/knn_search/KnnSearchResponse.ts +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -import { HitsMetadata } from '@global/search/_types/hits' -import { Dictionary } from '@spec_utils/Dictionary' -import { UserDefinedValue } from '@spec_utils/UserDefinedValue' -import { double, long } from '@_types/Numeric' -import { ShardStatistics } from '@_types/Stats' - -export class Response { - body: { - /** The milliseconds it took Elasticsearch to run the request. */ - took: long - /** - * If true, the request timed out before completion; - * returned results may be partial or empty. - */ - timed_out: boolean - /** - * A count of shards used for the request. - */ - _shards: ShardStatistics - /** - * The returned documents and metadata. - */ - hits: HitsMetadata - /** - * The field values for the documents. These fields - * must be specified in the request using the `fields` parameter. - */ - fields?: Dictionary - /** - * The highest returned document score. This value is null for requests - * that do not sort by score. - */ - max_score?: double - } -} diff --git a/specification/_global/knn_search/_types/Knn.ts b/specification/_global/knn_search/_types/Knn.ts deleted file mode 100644 index e16cff9d82..0000000000 --- a/specification/_global/knn_search/_types/Knn.ts +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -import { Field } from '@_types/common' -import { QueryVector } from '@_types/Knn' -import { integer } from '@_types/Numeric' - -export interface Query { - /** The name of the vector field to search against */ - field: Field - /** The query vector */ - query_vector: QueryVector - /** The final number of nearest neighbors to return as top hits */ - k: integer - /** The number of nearest neighbor candidates to consider per shard */ - num_candidates: integer -}