Skip to content

Commit 645657c

Browse files
authored
Remove old _knn_search tech preview API in v9 (#118104)
Removes the old `_knn_search` API that was never out of tech preview and deprecated throughout the v8 cycle. To utilize the API, `compatible-with=8` can be utilized.
1 parent 7759083 commit 645657c

File tree

9 files changed

+42
-165
lines changed

9 files changed

+42
-165
lines changed

docs/changelog/118104.yaml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
pr: 118104
2+
summary: Remove old `_knn_search` tech preview API in v9
3+
area: Vector Search
4+
type: breaking
5+
issues: []
6+
breaking:
7+
title: Remove old `_knn_search` tech preview API in v9
8+
area: REST API
9+
details: The original, tech-preview api for vector search, `_knn_search`, has been removed in v9. For all vector search
10+
operations, you should utilize the `_search` endpoint.
11+
impact: The `_knn_search` API is now inaccessible without providing a compatible-with flag for v8.
12+
notable: false

docs/reference/mapping/types/dense-vector.asciidoc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -232,8 +232,8 @@ it will be set to the length of the first vector added to the field.
232232

233233
`index`::
234234
(Optional, Boolean)
235-
If `true`, you can search this field using the <<knn-search-api, kNN search
236-
API>>. Defaults to `true`.
235+
If `true`, you can search this field using the <<query-dsl-knn-query, knn query>>
236+
or <<search-api-knn, knn in _search>> . Defaults to `true`.
237237

238238
[[dense-vector-similarity]]
239239
`similarity`::

docs/reference/redirects.asciidoc

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1942,3 +1942,8 @@ Refer to <<get-ip-location-database-api>>.
19421942
=== Delete geoip database configuration API
19431943

19441944
Refer to <<delete-ip-location-database-api>>.
1945+
1946+
[role="exclude",id="knn-search-api"]
1947+
=== Delete _knn_search API
1948+
1949+
Refer to <<search-api-knn>>.

docs/reference/search.asciidoc

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,6 @@ include::search/async-search.asciidoc[]
5050

5151
include::search/point-in-time-api.asciidoc[]
5252

53-
include::search/knn-search.asciidoc[]
54-
5553
include::search/retriever.asciidoc[]
5654

5755
include::search/rrf.asciidoc[]

docs/reference/search/knn-search.asciidoc

Lines changed: 0 additions & 146 deletions
This file was deleted.

docs/reference/search/search-your-data/knn-search.asciidoc

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1058,8 +1058,10 @@ PUT image-index
10581058
* When using kNN search in <<modules-cross-cluster-search,{ccs}>>, the <<ccs-min-roundtrips,`ccs_minimize_roundtrips`>>
10591059
option is not supported.
10601060

1061-
* {blank}
1062-
include::{es-ref-dir}/search/knn-search.asciidoc[tag=hnsw-algorithm]
1061+
* {es} uses the https://arxiv.org/abs/1603.09320[HNSW algorithm] to support
1062+
efficient kNN search. Like most kNN algorithms, HNSW is an approximate method
1063+
that sacrifices result accuracy for improved search speed. This means the
1064+
results returned are not always the true _k_ closest neighbors.
10631065

10641066
NOTE: Approximate kNN search always uses the
10651067
<<dfs-query-then-fetch,`dfs_query_then_fetch`>> search type in order to gather

rest-api-spec/src/yamlRestTest/resources/rest-api-spec/test/search.vectors/40_knn_search.yml

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -215,8 +215,11 @@ setup:
215215
---
216216
"kNN search in _knn_search endpoint":
217217
- skip:
218-
features: [ "allowed_warnings" ]
218+
features: [ "allowed_warnings", "headers" ]
219219
- do:
220+
headers:
221+
Content-Type: "application/vnd.elasticsearch+json;compatible-with=8"
222+
Accept: "application/vnd.elasticsearch+json;compatible-with=8"
220223
allowed_warnings:
221224
- "The kNN search API has been replaced by the `knn` option in the search API."
222225
knn_search:
@@ -240,8 +243,11 @@ setup:
240243
- requires:
241244
cluster_features: "gte_v8.2.0"
242245
reason: 'kNN with filtering added in 8.2'
243-
test_runner_features: [ "allowed_warnings" ]
246+
test_runner_features: [ "allowed_warnings", "headers" ]
244247
- do:
248+
headers:
249+
Content-Type: "application/vnd.elasticsearch+json;compatible-with=8"
250+
Accept: "application/vnd.elasticsearch+json;compatible-with=8"
245251
allowed_warnings:
246252
- "The kNN search API has been replaced by the `knn` option in the search API."
247253
knn_search:
@@ -262,6 +268,9 @@ setup:
262268
- match: { hits.hits.0.fields.name.0: "rabbit.jpg" }
263269

264270
- do:
271+
headers:
272+
Content-Type: "application/vnd.elasticsearch+json;compatible-with=8"
273+
Accept: "application/vnd.elasticsearch+json;compatible-with=8"
265274
allowed_warnings:
266275
- "The kNN search API has been replaced by the `knn` option in the search API."
267276
knn_search:

rest-api-spec/src/yamlRestTest/resources/rest-api-spec/test/search.vectors/50_dense_vector_field_usage.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,9 @@ setup:
5555
reason: 'dense_vector field usage was added in 8.1'
5656
test_runner_features: ["allowed_warnings"]
5757
- do:
58+
headers:
59+
Content-Type: "application/vnd.elasticsearch+json;compatible-with=8"
60+
Accept: "application/vnd.elasticsearch+json;compatible-with=8"
5861
allowed_warnings:
5962
- "The kNN search API has been replaced by the `knn` option in the search API."
6063
knn_search:

server/src/main/java/org/elasticsearch/rest/action/search/RestKnnSearchAction.java

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@
1111

1212
import org.elasticsearch.action.search.SearchRequestBuilder;
1313
import org.elasticsearch.client.internal.node.NodeClient;
14-
import org.elasticsearch.core.UpdateForV9;
14+
import org.elasticsearch.core.RestApiVersion;
15+
import org.elasticsearch.core.UpdateForV10;
1516
import org.elasticsearch.rest.BaseRestHandler;
1617
import org.elasticsearch.rest.RestRequest;
1718
import org.elasticsearch.rest.action.RestCancellableNodeClient;
@@ -34,19 +35,12 @@ public class RestKnnSearchAction extends BaseRestHandler {
3435

3536
public RestKnnSearchAction() {}
3637

37-
@UpdateForV9(owner = UpdateForV9.Owner.SEARCH_RELEVANCE)
38-
// these routes were ".deprecated" in RestApiVersion.V_8 which will require use of REST API compatibility headers to access
39-
// this API in v9. It is unclear if this was intentional for v9, and the code has been updated to ".deprecateAndKeep" which will
40-
// continue to emit deprecations warnings but will not require any special headers to access the API in v9.
41-
// Please review and update the code and tests as needed. The original code remains commented out below for reference.
4238
@Override
39+
@UpdateForV10(owner = UpdateForV10.Owner.SEARCH_RELEVANCE)
4340
public List<Route> routes() {
44-
4541
return List.of(
46-
// Route.builder(GET, "{index}/_knn_search").deprecated(DEPRECATION_MESSAGE, RestApiVersion.V_8).build(),
47-
// Route.builder(POST, "{index}/_knn_search").deprecated(DEPRECATION_MESSAGE, RestApiVersion.V_8).build()
48-
Route.builder(GET, "{index}/_knn_search").deprecateAndKeep(DEPRECATION_MESSAGE).build(),
49-
Route.builder(POST, "{index}/_knn_search").deprecateAndKeep(DEPRECATION_MESSAGE).build()
42+
Route.builder(GET, "{index}/_knn_search").deprecatedForRemoval(DEPRECATION_MESSAGE, RestApiVersion.V_8).build(),
43+
Route.builder(POST, "{index}/_knn_search").deprecatedForRemoval(DEPRECATION_MESSAGE, RestApiVersion.V_8).build()
5044
);
5145
}
5246

0 commit comments

Comments
 (0)