From 0dc193d8960d41e668a07094d510d529b626a9af Mon Sep 17 00:00:00 2001 From: Elastic Machine Date: Mon, 14 Apr 2025 16:11:26 +0000 Subject: [PATCH] Auto-generated API code --- elasticsearch/_async/client/__init__.py | 121 ------------------------ elasticsearch/_sync/client/__init__.py | 121 ------------------------ 2 files changed, 242 deletions(-) diff --git a/elasticsearch/_async/client/__init__.py b/elasticsearch/_async/client/__init__.py index dd69cc9e7..97765ed16 100644 --- a/elasticsearch/_async/client/__init__.py +++ b/elasticsearch/_async/client/__init__.py @@ -2999,127 +2999,6 @@ async def info( path_parts=__path_parts, ) - @_rewrite_parameters( - body_fields=( - "knn", - "docvalue_fields", - "fields", - "filter", - "source", - "stored_fields", - ), - parameter_aliases={"_source": "source"}, - ) - @_stability_warning(Stability.EXPERIMENTAL) - async def knn_search( - self, - *, - index: t.Union[str, t.Sequence[str]], - knn: t.Optional[t.Mapping[str, t.Any]] = None, - docvalue_fields: t.Optional[t.Sequence[t.Mapping[str, t.Any]]] = None, - error_trace: t.Optional[bool] = None, - fields: t.Optional[t.Union[str, t.Sequence[str]]] = None, - filter: t.Optional[ - t.Union[t.Mapping[str, t.Any], t.Sequence[t.Mapping[str, t.Any]]] - ] = None, - filter_path: t.Optional[t.Union[str, t.Sequence[str]]] = None, - human: t.Optional[bool] = None, - pretty: t.Optional[bool] = None, - routing: t.Optional[str] = None, - source: t.Optional[t.Union[bool, t.Mapping[str, t.Any]]] = None, - stored_fields: t.Optional[t.Union[str, t.Sequence[str]]] = None, - body: t.Optional[t.Dict[str, t.Any]] = None, - ) -> ObjectApiResponse[t.Any]: - """ - .. raw:: html - -

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:

- - - - ``_ - - :param index: A comma-separated list of index names to search; use `_all` or - to perform the operation on all indices. - :param knn: The kNN query to run. - :param docvalue_fields: The request returns doc values for field names matching - these patterns in the `hits.fields` property of the response. It accepts - wildcard (`*`) patterns. - :param fields: The request returns values for field names matching these patterns - in the `hits.fields` property of the response. It accepts wildcard (`*`) - patterns. - :param filter: 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. - :param routing: A comma-separated list of specific routing values. - :param source: Indicates which source fields are returned for matching documents. - These fields are returned in the `hits._source` property of the search response. - :param stored_fields: 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. - """ - if index in SKIP_IN_PATH: - raise ValueError("Empty value passed for parameter 'index'") - if knn is None and body is None: - raise ValueError("Empty value passed for parameter 'knn'") - __path_parts: t.Dict[str, str] = {"index": _quote(index)} - __path = f'/{__path_parts["index"]}/_knn_search' - __query: t.Dict[str, t.Any] = {} - __body: t.Dict[str, t.Any] = body if body is not None else {} - if error_trace is not None: - __query["error_trace"] = error_trace - if filter_path is not None: - __query["filter_path"] = filter_path - if human is not None: - __query["human"] = human - if pretty is not None: - __query["pretty"] = pretty - if routing is not None: - __query["routing"] = routing - if not __body: - if knn is not None: - __body["knn"] = knn - if docvalue_fields is not None: - __body["docvalue_fields"] = docvalue_fields - if fields is not None: - __body["fields"] = fields - if filter is not None: - __body["filter"] = filter - if source is not None: - __body["_source"] = source - if stored_fields is not None: - __body["stored_fields"] = stored_fields - if not __body: - __body = None # type: ignore[assignment] - __headers = {"accept": "application/json"} - if __body is not None: - __headers["content-type"] = "application/json" - return await self.perform_request( # type: ignore[return-value] - "POST", - __path, - params=__query, - headers=__headers, - body=__body, - endpoint_id="knn_search", - path_parts=__path_parts, - ) - @_rewrite_parameters( body_fields=("docs", "ids"), parameter_aliases={ diff --git a/elasticsearch/_sync/client/__init__.py b/elasticsearch/_sync/client/__init__.py index 6e97b41e6..56ecd4f2f 100644 --- a/elasticsearch/_sync/client/__init__.py +++ b/elasticsearch/_sync/client/__init__.py @@ -2997,127 +2997,6 @@ def info( path_parts=__path_parts, ) - @_rewrite_parameters( - body_fields=( - "knn", - "docvalue_fields", - "fields", - "filter", - "source", - "stored_fields", - ), - parameter_aliases={"_source": "source"}, - ) - @_stability_warning(Stability.EXPERIMENTAL) - def knn_search( - self, - *, - index: t.Union[str, t.Sequence[str]], - knn: t.Optional[t.Mapping[str, t.Any]] = None, - docvalue_fields: t.Optional[t.Sequence[t.Mapping[str, t.Any]]] = None, - error_trace: t.Optional[bool] = None, - fields: t.Optional[t.Union[str, t.Sequence[str]]] = None, - filter: t.Optional[ - t.Union[t.Mapping[str, t.Any], t.Sequence[t.Mapping[str, t.Any]]] - ] = None, - filter_path: t.Optional[t.Union[str, t.Sequence[str]]] = None, - human: t.Optional[bool] = None, - pretty: t.Optional[bool] = None, - routing: t.Optional[str] = None, - source: t.Optional[t.Union[bool, t.Mapping[str, t.Any]]] = None, - stored_fields: t.Optional[t.Union[str, t.Sequence[str]]] = None, - body: t.Optional[t.Dict[str, t.Any]] = None, - ) -> ObjectApiResponse[t.Any]: - """ - .. raw:: html - -

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:

- - - - ``_ - - :param index: A comma-separated list of index names to search; use `_all` or - to perform the operation on all indices. - :param knn: The kNN query to run. - :param docvalue_fields: The request returns doc values for field names matching - these patterns in the `hits.fields` property of the response. It accepts - wildcard (`*`) patterns. - :param fields: The request returns values for field names matching these patterns - in the `hits.fields` property of the response. It accepts wildcard (`*`) - patterns. - :param filter: 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. - :param routing: A comma-separated list of specific routing values. - :param source: Indicates which source fields are returned for matching documents. - These fields are returned in the `hits._source` property of the search response. - :param stored_fields: 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. - """ - if index in SKIP_IN_PATH: - raise ValueError("Empty value passed for parameter 'index'") - if knn is None and body is None: - raise ValueError("Empty value passed for parameter 'knn'") - __path_parts: t.Dict[str, str] = {"index": _quote(index)} - __path = f'/{__path_parts["index"]}/_knn_search' - __query: t.Dict[str, t.Any] = {} - __body: t.Dict[str, t.Any] = body if body is not None else {} - if error_trace is not None: - __query["error_trace"] = error_trace - if filter_path is not None: - __query["filter_path"] = filter_path - if human is not None: - __query["human"] = human - if pretty is not None: - __query["pretty"] = pretty - if routing is not None: - __query["routing"] = routing - if not __body: - if knn is not None: - __body["knn"] = knn - if docvalue_fields is not None: - __body["docvalue_fields"] = docvalue_fields - if fields is not None: - __body["fields"] = fields - if filter is not None: - __body["filter"] = filter - if source is not None: - __body["_source"] = source - if stored_fields is not None: - __body["stored_fields"] = stored_fields - if not __body: - __body = None # type: ignore[assignment] - __headers = {"accept": "application/json"} - if __body is not None: - __headers["content-type"] = "application/json" - return self.perform_request( # type: ignore[return-value] - "POST", - __path, - params=__query, - headers=__headers, - body=__body, - endpoint_id="knn_search", - path_parts=__path_parts, - ) - @_rewrite_parameters( body_fields=("docs", "ids"), parameter_aliases={