spring-projects / spring-data-elasticsearch

Provide support to increase developer productivity in Java when using Elasticsearch. Uses familiar Spring concepts such as a template classes for core API usage and lightweight repository style data access.
https://spring.io/projects/spring-data-elasticsearch/
Apache License 2.0
2.9k stars 1.33k forks source link

Add knn search parameter and remove knn query #2919

Closed puppylpg closed 3 months ago

puppylpg commented 4 months ago

KnnQuery and KnnSearch are two different classes in elasticsearch java client and are for different queries:

They both have different parameters and different classes in elasticsearch java client. However, in the current spring data elasticsearch implementation, they are mixed together and are all converted into KnnSearch finally.

So I wanna submit a PR to:

  1. remove KnnQuery in NativeQuery: and I think this clause should be constructed inside the co.elastic.clients.elasticsearch._types.query_dsl.Query in NativeQuery by user manually;
  2. add withKnnSearches method in NativeQueryBuilder: this may be a loss without which KnnSearch can't be constructed by user;
  3. add knn search mapping parameters in elasticsearch 8;

If there are questions about the issues above, we can discuss further.