Class KnnSearchRequest

java.lang.Object
co.elastic.clients.elasticsearch._types.RequestBase
co.elastic.clients.elasticsearch.core.KnnSearchRequest
All Implemented Interfaces:
JsonpSerializable

@Deprecated @JsonpDeserializable public class KnnSearchRequest extends RequestBase implements JsonpSerializable
Deprecated.
8.4.0 The kNN search API has been replaced by the knn option in the search API.
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.

See Also:
  • Field Details

  • Method Details

    • of

      Deprecated.
    • source

      @Nullable public final SourceConfig source()
      Deprecated.
      Indicates which source fields are returned for matching documents. These fields are returned in the hits._source property of the search response.

      API name: _source

    • docvalueFields

      public final List<FieldAndFormat> docvalueFields()
      Deprecated.
      The request returns doc values for field names matching these patterns in the hits.fields property of the response. Accepts wildcard (*) patterns.

      API name: docvalue_fields

    • fields

      public final List<String> fields()
      Deprecated.
      The request returns values for field names matching these patterns in the hits.fields property of the response. Accepts wildcard (*) patterns.

      API name: fields

    • filter

      public final List<Query> filter()
      Deprecated.
      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.

      API name: filter

    • index

      public final List<String> index()
      Deprecated.
      Required - A comma-separated list of index names to search; use _all or to perform the operation on all indices

      API name: index

    • knn

      public final KnnSearchQuery knn()
      Deprecated.
      Required - kNN query to execute

      API name: knn

    • routing

      @Nullable public final String routing()
      Deprecated.
      A comma-separated list of specific routing values

      API name: routing

    • storedFields

      public final List<String> storedFields()
      Deprecated.
      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.

      API name: stored_fields

    • serialize

      public void serialize(jakarta.json.stream.JsonGenerator generator, JsonpMapper mapper)
      Deprecated.
      Serialize this object to JSON.
      Specified by:
      serialize in interface JsonpSerializable
    • serializeInternal

      protected void serializeInternal(jakarta.json.stream.JsonGenerator generator, JsonpMapper mapper)
      Deprecated.
    • setupKnnSearchRequestDeserializer

      protected static void setupKnnSearchRequestDeserializer(ObjectDeserializer<KnnSearchRequest.Builder> op)
      Deprecated.
    • createKnnSearchEndpoint

      public static <TDocument> Endpoint<KnnSearchRequest,KnnSearchResponse<TDocument>,ErrorResponse> createKnnSearchEndpoint(JsonpDeserializer<TDocument> tDocumentDeserializer)
      Deprecated.
      Create an "knn_search" endpoint.