diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/knn_search.rb b/elasticsearch-api/lib/elasticsearch/api/actions/knn_search.rb deleted file mode 100644 index 4da3c30b2c..0000000000 --- a/elasticsearch-api/lib/elasticsearch/api/actions/knn_search.rb +++ /dev/null @@ -1,82 +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. -# -# This code was automatically generated from the Elasticsearch Specification -# See https://github.com/elastic/elasticsearch-specification -# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. -module Elasticsearch - module API - module Actions - # 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. - # This functionality is Experimental and may be changed or removed - # completely in a future release. Elastic will take a best effort approach - # to fix any issues, but experimental features are not subject to the - # support SLA of official GA features. - # - # @option arguments [String, Array] :index A comma-separated list of index names to search; - # use +_all+ or to perform the operation on all indices. (*Required*) - # @option arguments [String] :routing A comma-separated list of specific routing values. - # @option arguments [Hash] :headers Custom HTTP headers - # @option arguments [Hash] :body request body - # - # @see https://www.elastic.co/docs/api/doc/elasticsearch/v9/operation/operation-knn-search - # - def knn_search(arguments = {}) - request_opts = { endpoint: arguments[:endpoint] || 'knn_search' } - - defined_params = [:index].each_with_object({}) do |variable, set_variables| - set_variables[variable] = arguments[variable] if arguments.key?(variable) - end - request_opts[:defined_params] = defined_params unless defined_params.empty? - - raise ArgumentError, "Required argument 'index' missing" unless arguments[:index] - - arguments = arguments.clone - headers = arguments.delete(:headers) || {} - - body = arguments.delete(:body) - - _index = arguments.delete(:index) - - method = if body - Elasticsearch::API::HTTP_POST - else - Elasticsearch::API::HTTP_GET - end - - path = "#{Utils.listify(_index)}/_knn_search" - params = Utils.process_params(arguments) - - Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers, request_opts) - ) - end - end - end -end diff --git a/elasticsearch-api/lib/elasticsearch/api/version.rb b/elasticsearch-api/lib/elasticsearch/api/version.rb index 7856a13f24..18bfc42146 100644 --- a/elasticsearch-api/lib/elasticsearch/api/version.rb +++ b/elasticsearch-api/lib/elasticsearch/api/version.rb @@ -18,6 +18,6 @@ module Elasticsearch module API VERSION = '9.0.0'.freeze - ES_SPECIFICATION_COMMIT = '4396e621134e40fe50a4b770c0487c1770763e43'.freeze + ES_SPECIFICATION_COMMIT = 'c02d8eb89a4efb3e719bd783715e2bf312479af8'.freeze end end diff --git a/elasticsearch-api/spec/unit/actions/knn_search_spec.rb b/elasticsearch-api/spec/unit/actions/knn_search_spec.rb deleted file mode 100644 index 2400b84238..0000000000 --- a/elasticsearch-api/spec/unit/actions/knn_search_spec.rb +++ /dev/null @@ -1,35 +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. - -require 'spec_helper' - -describe 'client#knn_search' do - let(:expected_args) do - [ - 'GET', - 'foo/_knn_search', - { }, - nil, - {}, - { endpoint: 'knn_search', defined_params: { index: 'foo' } } - ] - end - - it 'performs the request' do - expect(client_double.knn_search(index: 'foo')).to be_a Elasticsearch::API::Response - end -end diff --git a/elasticsearch-api/spec/unit/perform_request_spec.rb b/elasticsearch-api/spec/unit/perform_request_spec.rb index cade50b6f1..8a9f98e0ae 100644 --- a/elasticsearch-api/spec/unit/perform_request_spec.rb +++ b/elasticsearch-api/spec/unit/perform_request_spec.rb @@ -27,7 +27,7 @@ spec.visibility != 'public' || # TODO: Once the test suite is migrated to elasticsearch-specification, these should be removed spec.module_namespace.flatten.first == 'rollup' || - ['scroll', 'clear_scroll', 'connector.last_sync'].include?(spec.endpoint_name) + ['scroll', 'clear_scroll', 'connector.last_sync', 'knn_search'].include?(spec.endpoint_name) # These are the path parts defined by the user in the method argument defined_path_parts = spec.path_params.inject({}) do |params, part|