Skip to content

Auto-generated code for 9.0 #2920

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 14, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
121 changes: 0 additions & 121 deletions elasticsearch/_async/client/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

<p>Run a knn search.</p>
<p>NOTE: The kNN search API has been replaced by the <code>knn</code> option in the search API.</p>
<p>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.</p>
<p>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.</p>
<p>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.</p>
<p>A kNN search response has the exact same structure as a search API response.
However, certain sections have a meaning specific to kNN search:</p>
<ul>
<li>The document <code>_score</code> is determined by the similarity between the query and document vector.</li>
<li>The <code>hits.total</code> object contains the total number of nearest neighbor candidates considered, which is <code>num_candidates * num_shards</code>. The <code>hits.total.relation</code> will always be <code>eq</code>, indicating an exact value.</li>
</ul>


`<https://www.elastic.co/docs/api/doc/elasticsearch/v9/operation/operation-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={
Expand Down
121 changes: 0 additions & 121 deletions elasticsearch/_sync/client/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

<p>Run a knn search.</p>
<p>NOTE: The kNN search API has been replaced by the <code>knn</code> option in the search API.</p>
<p>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.</p>
<p>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.</p>
<p>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.</p>
<p>A kNN search response has the exact same structure as a search API response.
However, certain sections have a meaning specific to kNN search:</p>
<ul>
<li>The document <code>_score</code> is determined by the similarity between the query and document vector.</li>
<li>The <code>hits.total</code> object contains the total number of nearest neighbor candidates considered, which is <code>num_candidates * num_shards</code>. The <code>hits.total.relation</code> will always be <code>eq</code>, indicating an exact value.</li>
</ul>


`<https://www.elastic.co/docs/api/doc/elasticsearch/v9/operation/operation-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={
Expand Down