Skip to content

Auto-generated code for main #2919

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/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
4 changes: 2 additions & 2 deletions elasticsearch/_async/client/connector.py
Original file line number Diff line number Diff line change
Expand Up @@ -1539,7 +1539,7 @@ async def update_filtering_validation(
<p>Update the draft filtering validation info for a connector.</p>


`<https://www.elastic.co/guide/en/elasticsearch/reference/master/update-connector-filtering-validation-api.html>`_
`<https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-connector-update-filtering-validation>`_

:param connector_id: The unique identifier of the connector to be updated
:param validation:
Expand Down Expand Up @@ -1710,7 +1710,7 @@ async def update_native(
<p>Update the connector is_native flag.</p>


`<https://www.elastic.co/guide/en/elasticsearch/reference/master/update-connector-native-api.html>`_
`<https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-connector-update-native>`_

:param connector_id: The unique identifier of the connector to be updated
:param is_native:
Expand Down
2 changes: 1 addition & 1 deletion elasticsearch/_async/client/esql.py
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,7 @@ async def async_query_stop(
If the Elasticsearch security features are enabled, only the user who first submitted the ES|QL query can stop it.</p>


`<https://www.elastic.co/guide/en/elasticsearch/reference/master/esql-async-query-stop-api.html>`_
`<https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-esql-async-query-stop>`_

:param id: The unique identifier of the query. A query ID is provided in the
ES|QL async query API response for a query that does not complete in the
Expand Down
8 changes: 4 additions & 4 deletions elasticsearch/_async/client/indices.py
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ async def cancel_migrate_reindex(
<p>Cancel a migration reindex attempt for a data stream or index.</p>


`<https://www.elastic.co/guide/en/elasticsearch/reference/master/migrate-data-stream.html>`_
`<https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-indices-cancel-migrate-reindex>`_

:param index: The index or data stream name
"""
Expand Down Expand Up @@ -794,7 +794,7 @@ async def create_from(
<p>Copy the mappings and settings from the source index to a destination index while allowing request settings and mappings to override the source values.</p>


`<https://www.elastic.co/guide/en/elasticsearch/reference/master/migrate-data-stream.html>`_
`<https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-indices-create-from>`_

:param source: The source index or data stream name
:param dest: The destination index or data stream name
Expand Down Expand Up @@ -2728,7 +2728,7 @@ async def get_migrate_reindex_status(
<p>Get the status of a migration reindex attempt for a data stream or index.</p>


`<https://www.elastic.co/guide/en/elasticsearch/reference/master/migrate-data-stream.html>`_
`<https://www.elastic.co/docs/api/doc/elasticsearch/group/endpoint-migration>`_

:param index: The index or data stream name.
"""
Expand Down Expand Up @@ -2947,7 +2947,7 @@ async def migrate_reindex(
The persistent task ID is returned immediately and the reindexing work is completed in that task.</p>


`<https://www.elastic.co/guide/en/elasticsearch/reference/master/migrate-data-stream.html>`_
`<https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-indices-migrate-reindex>`_

:param reindex:
"""
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/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
4 changes: 2 additions & 2 deletions elasticsearch/_sync/client/connector.py
Original file line number Diff line number Diff line change
Expand Up @@ -1539,7 +1539,7 @@ def update_filtering_validation(
<p>Update the draft filtering validation info for a connector.</p>


`<https://www.elastic.co/guide/en/elasticsearch/reference/master/update-connector-filtering-validation-api.html>`_
`<https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-connector-update-filtering-validation>`_

:param connector_id: The unique identifier of the connector to be updated
:param validation:
Expand Down Expand Up @@ -1710,7 +1710,7 @@ def update_native(
<p>Update the connector is_native flag.</p>


`<https://www.elastic.co/guide/en/elasticsearch/reference/master/update-connector-native-api.html>`_
`<https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-connector-update-native>`_

:param connector_id: The unique identifier of the connector to be updated
:param is_native:
Expand Down
2 changes: 1 addition & 1 deletion elasticsearch/_sync/client/esql.py
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,7 @@ def async_query_stop(
If the Elasticsearch security features are enabled, only the user who first submitted the ES|QL query can stop it.</p>


`<https://www.elastic.co/guide/en/elasticsearch/reference/master/esql-async-query-stop-api.html>`_
`<https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-esql-async-query-stop>`_

:param id: The unique identifier of the query. A query ID is provided in the
ES|QL async query API response for a query that does not complete in the
Expand Down
8 changes: 4 additions & 4 deletions elasticsearch/_sync/client/indices.py
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ def cancel_migrate_reindex(
<p>Cancel a migration reindex attempt for a data stream or index.</p>


`<https://www.elastic.co/guide/en/elasticsearch/reference/master/migrate-data-stream.html>`_
`<https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-indices-cancel-migrate-reindex>`_

:param index: The index or data stream name
"""
Expand Down Expand Up @@ -794,7 +794,7 @@ def create_from(
<p>Copy the mappings and settings from the source index to a destination index while allowing request settings and mappings to override the source values.</p>


`<https://www.elastic.co/guide/en/elasticsearch/reference/master/migrate-data-stream.html>`_
`<https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-indices-create-from>`_

:param source: The source index or data stream name
:param dest: The destination index or data stream name
Expand Down Expand Up @@ -2728,7 +2728,7 @@ def get_migrate_reindex_status(
<p>Get the status of a migration reindex attempt for a data stream or index.</p>


`<https://www.elastic.co/guide/en/elasticsearch/reference/master/migrate-data-stream.html>`_
`<https://www.elastic.co/docs/api/doc/elasticsearch/group/endpoint-migration>`_

:param index: The index or data stream name.
"""
Expand Down Expand Up @@ -2947,7 +2947,7 @@ def migrate_reindex(
The persistent task ID is returned immediately and the reindexing work is completed in that task.</p>


`<https://www.elastic.co/guide/en/elasticsearch/reference/master/migrate-data-stream.html>`_
`<https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-indices-migrate-reindex>`_

:param reindex:
"""
Expand Down