elasticsearch 8.17.1__py3-none-any.whl → 9.0.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- elasticsearch/__init__.py +2 -2
- elasticsearch/_async/client/__init__.py +2125 -1053
- elasticsearch/_async/client/_base.py +1 -2
- elasticsearch/_async/client/async_search.py +46 -35
- elasticsearch/_async/client/autoscaling.py +32 -26
- elasticsearch/_async/client/cat.py +244 -176
- elasticsearch/_async/client/ccr.py +268 -128
- elasticsearch/_async/client/cluster.py +191 -164
- elasticsearch/_async/client/connector.py +226 -116
- elasticsearch/_async/client/dangling_indices.py +22 -16
- elasticsearch/_async/client/enrich.py +51 -11
- elasticsearch/_async/client/eql.py +54 -13
- elasticsearch/_async/client/esql.py +351 -7
- elasticsearch/_async/client/features.py +37 -27
- elasticsearch/_async/client/fleet.py +32 -22
- elasticsearch/_async/client/graph.py +10 -9
- elasticsearch/_async/client/ilm.py +115 -77
- elasticsearch/_async/client/indices.py +1119 -772
- elasticsearch/_async/client/inference.py +1933 -84
- elasticsearch/_async/client/ingest.py +83 -50
- elasticsearch/_async/client/license.py +90 -38
- elasticsearch/_async/client/logstash.py +20 -9
- elasticsearch/_async/client/migration.py +26 -17
- elasticsearch/_async/client/ml.py +646 -374
- elasticsearch/_async/client/monitoring.py +6 -3
- elasticsearch/_async/client/nodes.py +52 -54
- elasticsearch/_async/client/query_rules.py +59 -33
- elasticsearch/_async/client/rollup.py +124 -86
- elasticsearch/_async/client/search_application.py +60 -32
- elasticsearch/_async/client/searchable_snapshots.py +25 -12
- elasticsearch/_async/client/security.py +903 -562
- elasticsearch/_async/client/shutdown.py +34 -36
- elasticsearch/_async/client/simulate.py +22 -28
- elasticsearch/_async/client/slm.py +65 -40
- elasticsearch/_async/client/snapshot.py +454 -327
- elasticsearch/_async/client/sql.py +43 -22
- elasticsearch/_async/client/ssl.py +17 -18
- elasticsearch/_async/client/synonyms.py +58 -37
- elasticsearch/_async/client/tasks.py +77 -48
- elasticsearch/_async/client/text_structure.py +65 -56
- elasticsearch/_async/client/transform.py +124 -93
- elasticsearch/_async/client/watcher.py +117 -73
- elasticsearch/_async/client/xpack.py +18 -9
- elasticsearch/_async/helpers.py +1 -2
- elasticsearch/_sync/client/__init__.py +2125 -1053
- elasticsearch/_sync/client/_base.py +1 -2
- elasticsearch/_sync/client/async_search.py +46 -35
- elasticsearch/_sync/client/autoscaling.py +32 -26
- elasticsearch/_sync/client/cat.py +244 -176
- elasticsearch/_sync/client/ccr.py +268 -128
- elasticsearch/_sync/client/cluster.py +191 -164
- elasticsearch/_sync/client/connector.py +226 -116
- elasticsearch/_sync/client/dangling_indices.py +22 -16
- elasticsearch/_sync/client/enrich.py +51 -11
- elasticsearch/_sync/client/eql.py +54 -13
- elasticsearch/_sync/client/esql.py +351 -7
- elasticsearch/_sync/client/features.py +37 -27
- elasticsearch/_sync/client/fleet.py +32 -22
- elasticsearch/_sync/client/graph.py +10 -9
- elasticsearch/_sync/client/ilm.py +115 -77
- elasticsearch/_sync/client/indices.py +1119 -772
- elasticsearch/_sync/client/inference.py +1933 -84
- elasticsearch/_sync/client/ingest.py +83 -50
- elasticsearch/_sync/client/license.py +90 -38
- elasticsearch/_sync/client/logstash.py +20 -9
- elasticsearch/_sync/client/migration.py +26 -17
- elasticsearch/_sync/client/ml.py +646 -374
- elasticsearch/_sync/client/monitoring.py +6 -3
- elasticsearch/_sync/client/nodes.py +52 -54
- elasticsearch/_sync/client/query_rules.py +59 -33
- elasticsearch/_sync/client/rollup.py +124 -86
- elasticsearch/_sync/client/search_application.py +60 -32
- elasticsearch/_sync/client/searchable_snapshots.py +25 -12
- elasticsearch/_sync/client/security.py +903 -562
- elasticsearch/_sync/client/shutdown.py +34 -36
- elasticsearch/_sync/client/simulate.py +22 -28
- elasticsearch/_sync/client/slm.py +65 -40
- elasticsearch/_sync/client/snapshot.py +454 -327
- elasticsearch/_sync/client/sql.py +43 -22
- elasticsearch/_sync/client/ssl.py +17 -18
- elasticsearch/_sync/client/synonyms.py +58 -37
- elasticsearch/_sync/client/tasks.py +77 -48
- elasticsearch/_sync/client/text_structure.py +65 -56
- elasticsearch/_sync/client/transform.py +124 -93
- elasticsearch/_sync/client/utils.py +1 -41
- elasticsearch/_sync/client/watcher.py +117 -73
- elasticsearch/_sync/client/xpack.py +18 -9
- elasticsearch/_version.py +1 -1
- elasticsearch/client.py +2 -0
- elasticsearch/dsl/__init__.py +203 -0
- elasticsearch/dsl/_async/__init__.py +16 -0
- elasticsearch/dsl/_async/document.py +522 -0
- elasticsearch/dsl/_async/faceted_search.py +50 -0
- elasticsearch/dsl/_async/index.py +639 -0
- elasticsearch/dsl/_async/mapping.py +49 -0
- elasticsearch/dsl/_async/search.py +237 -0
- elasticsearch/dsl/_async/update_by_query.py +47 -0
- elasticsearch/dsl/_sync/__init__.py +16 -0
- elasticsearch/dsl/_sync/document.py +514 -0
- elasticsearch/dsl/_sync/faceted_search.py +50 -0
- elasticsearch/dsl/_sync/index.py +597 -0
- elasticsearch/dsl/_sync/mapping.py +49 -0
- elasticsearch/dsl/_sync/search.py +230 -0
- elasticsearch/dsl/_sync/update_by_query.py +45 -0
- elasticsearch/dsl/aggs.py +3734 -0
- elasticsearch/dsl/analysis.py +341 -0
- elasticsearch/dsl/async_connections.py +37 -0
- elasticsearch/dsl/connections.py +142 -0
- elasticsearch/dsl/document.py +20 -0
- elasticsearch/dsl/document_base.py +444 -0
- elasticsearch/dsl/exceptions.py +32 -0
- elasticsearch/dsl/faceted_search.py +28 -0
- elasticsearch/dsl/faceted_search_base.py +489 -0
- elasticsearch/dsl/field.py +4392 -0
- elasticsearch/dsl/function.py +180 -0
- elasticsearch/dsl/index.py +23 -0
- elasticsearch/dsl/index_base.py +178 -0
- elasticsearch/dsl/mapping.py +19 -0
- elasticsearch/dsl/mapping_base.py +219 -0
- elasticsearch/dsl/query.py +2822 -0
- elasticsearch/dsl/response/__init__.py +388 -0
- elasticsearch/dsl/response/aggs.py +100 -0
- elasticsearch/dsl/response/hit.py +53 -0
- elasticsearch/dsl/search.py +20 -0
- elasticsearch/dsl/search_base.py +1053 -0
- elasticsearch/dsl/serializer.py +34 -0
- elasticsearch/dsl/types.py +6453 -0
- elasticsearch/dsl/update_by_query.py +19 -0
- elasticsearch/dsl/update_by_query_base.py +149 -0
- elasticsearch/dsl/utils.py +687 -0
- elasticsearch/dsl/wrappers.py +144 -0
- elasticsearch/helpers/actions.py +1 -1
- elasticsearch/helpers/vectorstore/_async/strategies.py +12 -12
- elasticsearch/helpers/vectorstore/_sync/strategies.py +12 -12
- elasticsearch/helpers/vectorstore/_sync/vectorstore.py +4 -1
- {elasticsearch-8.17.1.dist-info → elasticsearch-9.0.0.dist-info}/METADATA +12 -15
- elasticsearch-9.0.0.dist-info/RECORD +160 -0
- elasticsearch/transport.py +0 -57
- elasticsearch-8.17.1.dist-info/RECORD +0 -119
- {elasticsearch-8.17.1.dist-info → elasticsearch-9.0.0.dist-info}/WHEEL +0 -0
- {elasticsearch-8.17.1.dist-info → elasticsearch-9.0.0.dist-info}/licenses/LICENSE +0 -0
- {elasticsearch-8.17.1.dist-info → elasticsearch-9.0.0.dist-info}/licenses/NOTICE +0 -0
|
@@ -18,7 +18,6 @@
|
|
|
18
18
|
|
|
19
19
|
import logging
|
|
20
20
|
import typing as t
|
|
21
|
-
import warnings
|
|
22
21
|
|
|
23
22
|
from elastic_transport import (
|
|
24
23
|
AsyncTransport,
|
|
@@ -181,37 +180,13 @@ class AsyncElasticsearch(BaseClient):
|
|
|
181
180
|
t.Callable[[t.Dict[str, t.Any], NodeConfig], t.Optional[NodeConfig]]
|
|
182
181
|
] = None,
|
|
183
182
|
meta_header: t.Union[DefaultType, bool] = DEFAULT,
|
|
184
|
-
timeout: t.Union[DefaultType, None, float] = DEFAULT,
|
|
185
|
-
randomize_hosts: t.Union[DefaultType, bool] = DEFAULT,
|
|
186
|
-
host_info_callback: t.Optional[
|
|
187
|
-
t.Callable[
|
|
188
|
-
[t.Dict[str, t.Any], t.Dict[str, t.Union[str, int]]],
|
|
189
|
-
t.Optional[t.Dict[str, t.Union[str, int]]],
|
|
190
|
-
]
|
|
191
|
-
] = None,
|
|
192
|
-
sniffer_timeout: t.Union[DefaultType, None, float] = DEFAULT,
|
|
193
|
-
sniff_on_connection_fail: t.Union[DefaultType, bool] = DEFAULT,
|
|
194
183
|
http_auth: t.Union[DefaultType, t.Any] = DEFAULT,
|
|
195
|
-
maxsize: t.Union[DefaultType, int] = DEFAULT,
|
|
196
184
|
# Internal use only
|
|
197
185
|
_transport: t.Optional[AsyncTransport] = None,
|
|
198
186
|
) -> None:
|
|
199
187
|
if hosts is None and cloud_id is None and _transport is None:
|
|
200
188
|
raise ValueError("Either 'hosts' or 'cloud_id' must be specified")
|
|
201
189
|
|
|
202
|
-
if timeout is not DEFAULT:
|
|
203
|
-
if request_timeout is not DEFAULT:
|
|
204
|
-
raise ValueError(
|
|
205
|
-
"Can't specify both 'timeout' and 'request_timeout', "
|
|
206
|
-
"instead only specify 'request_timeout'"
|
|
207
|
-
)
|
|
208
|
-
warnings.warn(
|
|
209
|
-
"The 'timeout' parameter is deprecated in favor of 'request_timeout'",
|
|
210
|
-
category=DeprecationWarning,
|
|
211
|
-
stacklevel=2,
|
|
212
|
-
)
|
|
213
|
-
request_timeout = timeout
|
|
214
|
-
|
|
215
190
|
if serializer is not None:
|
|
216
191
|
if serializers is not DEFAULT:
|
|
217
192
|
raise ValueError(
|
|
@@ -220,58 +195,6 @@ class AsyncElasticsearch(BaseClient):
|
|
|
220
195
|
)
|
|
221
196
|
serializers = {default_mimetype: serializer}
|
|
222
197
|
|
|
223
|
-
if randomize_hosts is not DEFAULT:
|
|
224
|
-
if randomize_nodes_in_pool is not DEFAULT:
|
|
225
|
-
raise ValueError(
|
|
226
|
-
"Can't specify both 'randomize_hosts' and 'randomize_nodes_in_pool', "
|
|
227
|
-
"instead only specify 'randomize_nodes_in_pool'"
|
|
228
|
-
)
|
|
229
|
-
warnings.warn(
|
|
230
|
-
"The 'randomize_hosts' parameter is deprecated in favor of 'randomize_nodes_in_pool'",
|
|
231
|
-
category=DeprecationWarning,
|
|
232
|
-
stacklevel=2,
|
|
233
|
-
)
|
|
234
|
-
randomize_nodes_in_pool = randomize_hosts
|
|
235
|
-
|
|
236
|
-
if sniffer_timeout is not DEFAULT:
|
|
237
|
-
if min_delay_between_sniffing is not DEFAULT:
|
|
238
|
-
raise ValueError(
|
|
239
|
-
"Can't specify both 'sniffer_timeout' and 'min_delay_between_sniffing', "
|
|
240
|
-
"instead only specify 'min_delay_between_sniffing'"
|
|
241
|
-
)
|
|
242
|
-
warnings.warn(
|
|
243
|
-
"The 'sniffer_timeout' parameter is deprecated in favor of 'min_delay_between_sniffing'",
|
|
244
|
-
category=DeprecationWarning,
|
|
245
|
-
stacklevel=2,
|
|
246
|
-
)
|
|
247
|
-
min_delay_between_sniffing = sniffer_timeout
|
|
248
|
-
|
|
249
|
-
if sniff_on_connection_fail is not DEFAULT:
|
|
250
|
-
if sniff_on_node_failure is not DEFAULT:
|
|
251
|
-
raise ValueError(
|
|
252
|
-
"Can't specify both 'sniff_on_connection_fail' and 'sniff_on_node_failure', "
|
|
253
|
-
"instead only specify 'sniff_on_node_failure'"
|
|
254
|
-
)
|
|
255
|
-
warnings.warn(
|
|
256
|
-
"The 'sniff_on_connection_fail' parameter is deprecated in favor of 'sniff_on_node_failure'",
|
|
257
|
-
category=DeprecationWarning,
|
|
258
|
-
stacklevel=2,
|
|
259
|
-
)
|
|
260
|
-
sniff_on_node_failure = sniff_on_connection_fail
|
|
261
|
-
|
|
262
|
-
if maxsize is not DEFAULT:
|
|
263
|
-
if connections_per_node is not DEFAULT:
|
|
264
|
-
raise ValueError(
|
|
265
|
-
"Can't specify both 'maxsize' and 'connections_per_node', "
|
|
266
|
-
"instead only specify 'connections_per_node'"
|
|
267
|
-
)
|
|
268
|
-
warnings.warn(
|
|
269
|
-
"The 'maxsize' parameter is deprecated in favor of 'connections_per_node'",
|
|
270
|
-
category=DeprecationWarning,
|
|
271
|
-
stacklevel=2,
|
|
272
|
-
)
|
|
273
|
-
connections_per_node = maxsize
|
|
274
|
-
|
|
275
198
|
# Setting min_delay_between_sniffing=True implies sniff_before_requests=True
|
|
276
199
|
if min_delay_between_sniffing is not DEFAULT:
|
|
277
200
|
sniff_before_requests = True
|
|
@@ -293,22 +216,7 @@ class AsyncElasticsearch(BaseClient):
|
|
|
293
216
|
)
|
|
294
217
|
|
|
295
218
|
sniff_callback = None
|
|
296
|
-
if
|
|
297
|
-
if sniffed_node_callback is not None:
|
|
298
|
-
raise ValueError(
|
|
299
|
-
"Can't specify both 'host_info_callback' and 'sniffed_node_callback', "
|
|
300
|
-
"instead only specify 'sniffed_node_callback'"
|
|
301
|
-
)
|
|
302
|
-
warnings.warn(
|
|
303
|
-
"The 'host_info_callback' parameter is deprecated in favor of 'sniffed_node_callback'",
|
|
304
|
-
category=DeprecationWarning,
|
|
305
|
-
stacklevel=2,
|
|
306
|
-
)
|
|
307
|
-
|
|
308
|
-
sniff_callback = create_sniff_callback(
|
|
309
|
-
host_info_callback=host_info_callback
|
|
310
|
-
)
|
|
311
|
-
elif sniffed_node_callback is not None:
|
|
219
|
+
if sniffed_node_callback is not None:
|
|
312
220
|
sniff_callback = create_sniff_callback(
|
|
313
221
|
sniffed_node_callback=sniffed_node_callback
|
|
314
222
|
)
|
|
@@ -628,6 +536,7 @@ class AsyncElasticsearch(BaseClient):
|
|
|
628
536
|
error_trace: t.Optional[bool] = None,
|
|
629
537
|
filter_path: t.Optional[t.Union[str, t.Sequence[str]]] = None,
|
|
630
538
|
human: t.Optional[bool] = None,
|
|
539
|
+
include_source_on_error: t.Optional[bool] = None,
|
|
631
540
|
list_executed_pipelines: t.Optional[bool] = None,
|
|
632
541
|
pipeline: t.Optional[str] = None,
|
|
633
542
|
pretty: t.Optional[bool] = None,
|
|
@@ -646,89 +555,97 @@ class AsyncElasticsearch(BaseClient):
|
|
|
646
555
|
] = None,
|
|
647
556
|
) -> ObjectApiResponse[t.Any]:
|
|
648
557
|
"""
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
558
|
+
.. raw:: html
|
|
559
|
+
|
|
560
|
+
<p>Bulk index or delete documents.
|
|
561
|
+
Perform multiple <code>index</code>, <code>create</code>, <code>delete</code>, and <code>update</code> actions in a single request.
|
|
562
|
+
This reduces overhead and can greatly increase indexing speed.</p>
|
|
563
|
+
<p>If the Elasticsearch security features are enabled, you must have the following index privileges for the target data stream, index, or index alias:</p>
|
|
564
|
+
<ul>
|
|
565
|
+
<li>To use the <code>create</code> action, you must have the <code>create_doc</code>, <code>create</code>, <code>index</code>, or <code>write</code> index privilege. Data streams support only the <code>create</code> action.</li>
|
|
566
|
+
<li>To use the <code>index</code> action, you must have the <code>create</code>, <code>index</code>, or <code>write</code> index privilege.</li>
|
|
567
|
+
<li>To use the <code>delete</code> action, you must have the <code>delete</code> or <code>write</code> index privilege.</li>
|
|
568
|
+
<li>To use the <code>update</code> action, you must have the <code>index</code> or <code>write</code> index privilege.</li>
|
|
569
|
+
<li>To automatically create a data stream or index with a bulk API request, you must have the <code>auto_configure</code>, <code>create_index</code>, or <code>manage</code> index privilege.</li>
|
|
570
|
+
<li>To make the result of a bulk operation visible to search using the <code>refresh</code> parameter, you must have the <code>maintenance</code> or <code>manage</code> index privilege.</li>
|
|
571
|
+
</ul>
|
|
572
|
+
<p>Automatic data stream creation requires a matching index template with data stream enabled.</p>
|
|
573
|
+
<p>The actions are specified in the request body using a newline delimited JSON (NDJSON) structure:</p>
|
|
574
|
+
<pre><code>action_and_meta_data\\n
|
|
575
|
+
optional_source\\n
|
|
576
|
+
action_and_meta_data\\n
|
|
577
|
+
optional_source\\n
|
|
578
|
+
....
|
|
579
|
+
action_and_meta_data\\n
|
|
580
|
+
optional_source\\n
|
|
581
|
+
</code></pre>
|
|
582
|
+
<p>The <code>index</code> and <code>create</code> actions expect a source on the next line and have the same semantics as the <code>op_type</code> parameter in the standard index API.
|
|
583
|
+
A <code>create</code> action fails if a document with the same ID already exists in the target
|
|
584
|
+
An <code>index</code> action adds or replaces a document as necessary.</p>
|
|
585
|
+
<p>NOTE: Data streams support only the <code>create</code> action.
|
|
586
|
+
To update or delete a document in a data stream, you must target the backing index containing the document.</p>
|
|
587
|
+
<p>An <code>update</code> action expects that the partial doc, upsert, and script and its options are specified on the next line.</p>
|
|
588
|
+
<p>A <code>delete</code> action does not expect a source on the next line and has the same semantics as the standard delete API.</p>
|
|
589
|
+
<p>NOTE: The final line of data must end with a newline character (<code>\\n</code>).
|
|
590
|
+
Each newline character may be preceded by a carriage return (<code>\\r</code>).
|
|
591
|
+
When sending NDJSON data to the <code>_bulk</code> endpoint, use a <code>Content-Type</code> header of <code>application/json</code> or <code>application/x-ndjson</code>.
|
|
592
|
+
Because this format uses literal newline characters (<code>\\n</code>) as delimiters, make sure that the JSON actions and sources are not pretty printed.</p>
|
|
593
|
+
<p>If you provide a target in the request path, it is used for any actions that don't explicitly specify an <code>_index</code> argument.</p>
|
|
594
|
+
<p>A note on the format: the idea here is to make processing as fast as possible.
|
|
595
|
+
As some of the actions are redirected to other shards on other nodes, only <code>action_meta_data</code> is parsed on the receiving node side.</p>
|
|
596
|
+
<p>Client libraries using this protocol should try and strive to do something similar on the client side, and reduce buffering as much as possible.</p>
|
|
597
|
+
<p>There is no "correct" number of actions to perform in a single bulk request.
|
|
598
|
+
Experiment with different settings to find the optimal size for your particular workload.
|
|
599
|
+
Note that Elasticsearch limits the maximum size of a HTTP request to 100mb by default so clients must ensure that no request exceeds this size.
|
|
600
|
+
It is not possible to index a single document that exceeds the size limit, so you must pre-process any such documents into smaller pieces before sending them to Elasticsearch.
|
|
601
|
+
For instance, split documents into pages or chapters before indexing them, or store raw binary data in a system outside Elasticsearch and replace the raw data with a link to the external system in the documents that you send to Elasticsearch.</p>
|
|
602
|
+
<p><strong>Client suppport for bulk requests</strong></p>
|
|
603
|
+
<p>Some of the officially supported clients provide helpers to assist with bulk requests and reindexing:</p>
|
|
604
|
+
<ul>
|
|
605
|
+
<li>Go: Check out <code>esutil.BulkIndexer</code></li>
|
|
606
|
+
<li>Perl: Check out <code>Search::Elasticsearch::Client::5_0::Bulk</code> and <code>Search::Elasticsearch::Client::5_0::Scroll</code></li>
|
|
607
|
+
<li>Python: Check out <code>elasticsearch.helpers.*</code></li>
|
|
608
|
+
<li>JavaScript: Check out <code>client.helpers.*</code></li>
|
|
609
|
+
<li>.NET: Check out <code>BulkAllObservable</code></li>
|
|
610
|
+
<li>PHP: Check out bulk indexing.</li>
|
|
611
|
+
</ul>
|
|
612
|
+
<p><strong>Submitting bulk requests with cURL</strong></p>
|
|
613
|
+
<p>If you're providing text file input to <code>curl</code>, you must use the <code>--data-binary</code> flag instead of plain <code>-d</code>.
|
|
614
|
+
The latter doesn't preserve newlines. For example:</p>
|
|
615
|
+
<pre><code>$ cat requests
|
|
616
|
+
{ "index" : { "_index" : "test", "_id" : "1" } }
|
|
617
|
+
{ "field1" : "value1" }
|
|
618
|
+
$ curl -s -H "Content-Type: application/x-ndjson" -XPOST localhost:9200/_bulk --data-binary "@requests"; echo
|
|
619
|
+
{"took":7, "errors": false, "items":[{"index":{"_index":"test","_id":"1","_version":1,"result":"created","forced_refresh":false}}]}
|
|
620
|
+
</code></pre>
|
|
621
|
+
<p><strong>Optimistic concurrency control</strong></p>
|
|
622
|
+
<p>Each <code>index</code> and <code>delete</code> action within a bulk API call may include the <code>if_seq_no</code> and <code>if_primary_term</code> parameters in their respective action and meta data lines.
|
|
623
|
+
The <code>if_seq_no</code> and <code>if_primary_term</code> parameters control how operations are run, based on the last modification to existing documents. See Optimistic concurrency control for more details.</p>
|
|
624
|
+
<p><strong>Versioning</strong></p>
|
|
625
|
+
<p>Each bulk item can include the version value using the <code>version</code> field.
|
|
626
|
+
It automatically follows the behavior of the index or delete operation based on the <code>_version</code> mapping.
|
|
627
|
+
It also support the <code>version_type</code>.</p>
|
|
628
|
+
<p><strong>Routing</strong></p>
|
|
629
|
+
<p>Each bulk item can include the routing value using the <code>routing</code> field.
|
|
630
|
+
It automatically follows the behavior of the index or delete operation based on the <code>_routing</code> mapping.</p>
|
|
631
|
+
<p>NOTE: Data streams do not support custom routing unless they were created with the <code>allow_custom_routing</code> setting enabled in the template.</p>
|
|
632
|
+
<p><strong>Wait for active shards</strong></p>
|
|
633
|
+
<p>When making bulk calls, you can set the <code>wait_for_active_shards</code> parameter to require a minimum number of shard copies to be active before starting to process the bulk request.</p>
|
|
634
|
+
<p><strong>Refresh</strong></p>
|
|
635
|
+
<p>Control when the changes made by this request are visible to search.</p>
|
|
636
|
+
<p>NOTE: Only the shards that receive the bulk request will be affected by refresh.
|
|
637
|
+
Imagine a <code>_bulk?refresh=wait_for</code> request with three documents in it that happen to be routed to different shards in an index with five shards.
|
|
638
|
+
The request will only wait for those three shards to refresh.
|
|
639
|
+
The other two shards that make up the index do not participate in the <code>_bulk</code> request at all.</p>
|
|
640
|
+
|
|
641
|
+
|
|
642
|
+
`<https://www.elastic.co/docs/api/doc/elasticsearch/v9/operation/operation-bulk>`_
|
|
728
643
|
|
|
729
644
|
:param operations:
|
|
730
645
|
:param index: The name of the data stream, index, or index alias to perform bulk
|
|
731
646
|
actions on.
|
|
647
|
+
:param include_source_on_error: True or false if to include the document source
|
|
648
|
+
in the error message in case of parsing errors.
|
|
732
649
|
:param list_executed_pipelines: If `true`, the response will include the ingest
|
|
733
650
|
pipelines that were run for each index or create.
|
|
734
651
|
:param pipeline: The pipeline identifier to use to preprocess incoming documents.
|
|
@@ -786,6 +703,8 @@ class AsyncElasticsearch(BaseClient):
|
|
|
786
703
|
__query["filter_path"] = filter_path
|
|
787
704
|
if human is not None:
|
|
788
705
|
__query["human"] = human
|
|
706
|
+
if include_source_on_error is not None:
|
|
707
|
+
__query["include_source_on_error"] = include_source_on_error
|
|
789
708
|
if list_executed_pipelines is not None:
|
|
790
709
|
__query["list_executed_pipelines"] = list_executed_pipelines
|
|
791
710
|
if pipeline is not None:
|
|
@@ -839,10 +758,13 @@ class AsyncElasticsearch(BaseClient):
|
|
|
839
758
|
body: t.Optional[t.Dict[str, t.Any]] = None,
|
|
840
759
|
) -> ObjectApiResponse[t.Any]:
|
|
841
760
|
"""
|
|
842
|
-
|
|
843
|
-
|
|
761
|
+
.. raw:: html
|
|
762
|
+
|
|
763
|
+
<p>Clear a scrolling search.
|
|
764
|
+
Clear the search context and results for a scrolling search.</p>
|
|
765
|
+
|
|
844
766
|
|
|
845
|
-
`<https://www.elastic.co/
|
|
767
|
+
`<https://www.elastic.co/docs/api/doc/elasticsearch/v9/operation/operation-clear-scroll>`_
|
|
846
768
|
|
|
847
769
|
:param scroll_id: The scroll IDs to clear. To clear all scroll IDs, use `_all`.
|
|
848
770
|
"""
|
|
@@ -890,13 +812,16 @@ class AsyncElasticsearch(BaseClient):
|
|
|
890
812
|
body: t.Optional[t.Dict[str, t.Any]] = None,
|
|
891
813
|
) -> ObjectApiResponse[t.Any]:
|
|
892
814
|
"""
|
|
893
|
-
|
|
894
|
-
used in search requests. The `keep_alive` parameter tells Elasticsearch how long
|
|
895
|
-
it should persist. A point in time is automatically closed when the `keep_alive`
|
|
896
|
-
period has elapsed. However, keeping points in time has a cost; close them as
|
|
897
|
-
soon as they are no longer required for search requests.
|
|
815
|
+
.. raw:: html
|
|
898
816
|
|
|
899
|
-
|
|
817
|
+
<p>Close a point in time.
|
|
818
|
+
A point in time must be opened explicitly before being used in search requests.
|
|
819
|
+
The <code>keep_alive</code> parameter tells Elasticsearch how long it should persist.
|
|
820
|
+
A point in time is automatically closed when the <code>keep_alive</code> period has elapsed.
|
|
821
|
+
However, keeping points in time has a cost; close them as soon as they are no longer required for search requests.</p>
|
|
822
|
+
|
|
823
|
+
|
|
824
|
+
`<https://www.elastic.co/docs/api/doc/elasticsearch/v9/operation/operation-open-point-in-time>`_
|
|
900
825
|
|
|
901
826
|
:param id: The ID of the point-in-time.
|
|
902
827
|
"""
|
|
@@ -968,16 +893,19 @@ class AsyncElasticsearch(BaseClient):
|
|
|
968
893
|
body: t.Optional[t.Dict[str, t.Any]] = None,
|
|
969
894
|
) -> ObjectApiResponse[t.Any]:
|
|
970
895
|
"""
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
896
|
+
.. raw:: html
|
|
897
|
+
|
|
898
|
+
<p>Count search results.
|
|
899
|
+
Get the number of documents matching a query.</p>
|
|
900
|
+
<p>The query can be provided either by using a simple query string as a parameter, or by defining Query DSL within the request body.
|
|
901
|
+
The query is optional. When no query is provided, the API uses <code>match_all</code> to count all the documents.</p>
|
|
902
|
+
<p>The count API supports multi-target syntax. You can run a single count API search across multiple data streams and indices.</p>
|
|
903
|
+
<p>The operation is broadcast across all shards.
|
|
904
|
+
For each shard ID group, a replica is chosen and the search is run against it.
|
|
905
|
+
This means that replicas increase the scalability of the count.</p>
|
|
906
|
+
|
|
979
907
|
|
|
980
|
-
`<https://www.elastic.co/
|
|
908
|
+
`<https://www.elastic.co/docs/api/doc/elasticsearch/v9/operation/operation-count>`_
|
|
981
909
|
|
|
982
910
|
:param index: A comma-separated list of data streams, indices, and aliases to
|
|
983
911
|
search. It supports wildcards (`*`). To search all data streams and indices,
|
|
@@ -1012,10 +940,10 @@ class AsyncElasticsearch(BaseClient):
|
|
|
1012
940
|
in the result.
|
|
1013
941
|
:param preference: The node or shard the operation should be performed on. By
|
|
1014
942
|
default, it is random.
|
|
1015
|
-
:param q: The query in Lucene query string syntax.
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
943
|
+
:param q: The query in Lucene query string syntax. This parameter cannot be used
|
|
944
|
+
with a request body.
|
|
945
|
+
:param query: Defines the search query using Query DSL. A request body query
|
|
946
|
+
cannot be used with the `q` query string parameter.
|
|
1019
947
|
:param routing: A custom value used to route operations to a specific shard.
|
|
1020
948
|
:param terminate_after: The maximum number of documents to collect for each shard.
|
|
1021
949
|
If a query reaches this limit, Elasticsearch terminates the query early.
|
|
@@ -1101,11 +1029,17 @@ class AsyncElasticsearch(BaseClient):
|
|
|
1101
1029
|
error_trace: t.Optional[bool] = None,
|
|
1102
1030
|
filter_path: t.Optional[t.Union[str, t.Sequence[str]]] = None,
|
|
1103
1031
|
human: t.Optional[bool] = None,
|
|
1032
|
+
if_primary_term: t.Optional[int] = None,
|
|
1033
|
+
if_seq_no: t.Optional[int] = None,
|
|
1034
|
+
include_source_on_error: t.Optional[bool] = None,
|
|
1035
|
+
op_type: t.Optional[t.Union[str, t.Literal["create", "index"]]] = None,
|
|
1104
1036
|
pipeline: t.Optional[str] = None,
|
|
1105
1037
|
pretty: t.Optional[bool] = None,
|
|
1106
1038
|
refresh: t.Optional[
|
|
1107
1039
|
t.Union[bool, str, t.Literal["false", "true", "wait_for"]]
|
|
1108
1040
|
] = None,
|
|
1041
|
+
require_alias: t.Optional[bool] = None,
|
|
1042
|
+
require_data_stream: t.Optional[bool] = None,
|
|
1109
1043
|
routing: t.Optional[str] = None,
|
|
1110
1044
|
timeout: t.Optional[t.Union[str, t.Literal[-1], t.Literal[0]]] = None,
|
|
1111
1045
|
version: t.Optional[int] = None,
|
|
@@ -1117,38 +1051,115 @@ class AsyncElasticsearch(BaseClient):
|
|
|
1117
1051
|
] = None,
|
|
1118
1052
|
) -> ObjectApiResponse[t.Any]:
|
|
1119
1053
|
"""
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1054
|
+
.. raw:: html
|
|
1055
|
+
|
|
1056
|
+
<p>Create a new document in the index.</p>
|
|
1057
|
+
<p>You can index a new JSON document with the <code>/<target>/_doc/</code> or <code>/<target>/_create/<_id></code> APIs
|
|
1058
|
+
Using <code>_create</code> guarantees that the document is indexed only if it does not already exist.
|
|
1059
|
+
It returns a 409 response when a document with a same ID already exists in the index.
|
|
1060
|
+
To update an existing document, you must use the <code>/<target>/_doc/</code> API.</p>
|
|
1061
|
+
<p>If the Elasticsearch security features are enabled, you must have the following index privileges for the target data stream, index, or index alias:</p>
|
|
1062
|
+
<ul>
|
|
1063
|
+
<li>To add a document using the <code>PUT /<target>/_create/<_id></code> or <code>POST /<target>/_create/<_id></code> request formats, you must have the <code>create_doc</code>, <code>create</code>, <code>index</code>, or <code>write</code> index privilege.</li>
|
|
1064
|
+
<li>To automatically create a data stream or index with this API request, you must have the <code>auto_configure</code>, <code>create_index</code>, or <code>manage</code> index privilege.</li>
|
|
1065
|
+
</ul>
|
|
1066
|
+
<p>Automatic data stream creation requires a matching index template with data stream enabled.</p>
|
|
1067
|
+
<p><strong>Automatically create data streams and indices</strong></p>
|
|
1068
|
+
<p>If the request's target doesn't exist and matches an index template with a <code>data_stream</code> definition, the index operation automatically creates the data stream.</p>
|
|
1069
|
+
<p>If the target doesn't exist and doesn't match a data stream template, the operation automatically creates the index and applies any matching index templates.</p>
|
|
1070
|
+
<p>NOTE: Elasticsearch includes several built-in index templates. To avoid naming collisions with these templates, refer to index pattern documentation.</p>
|
|
1071
|
+
<p>If no mapping exists, the index operation creates a dynamic mapping.
|
|
1072
|
+
By default, new fields and objects are automatically added to the mapping if needed.</p>
|
|
1073
|
+
<p>Automatic index creation is controlled by the <code>action.auto_create_index</code> setting.
|
|
1074
|
+
If it is <code>true</code>, any index can be created automatically.
|
|
1075
|
+
You can modify this setting to explicitly allow or block automatic creation of indices that match specified patterns or set it to <code>false</code> to turn off automatic index creation entirely.
|
|
1076
|
+
Specify a comma-separated list of patterns you want to allow or prefix each pattern with <code>+</code> or <code>-</code> to indicate whether it should be allowed or blocked.
|
|
1077
|
+
When a list is specified, the default behaviour is to disallow.</p>
|
|
1078
|
+
<p>NOTE: The <code>action.auto_create_index</code> setting affects the automatic creation of indices only.
|
|
1079
|
+
It does not affect the creation of data streams.</p>
|
|
1080
|
+
<p><strong>Routing</strong></p>
|
|
1081
|
+
<p>By default, shard placement — or routing — is controlled by using a hash of the document's ID value.
|
|
1082
|
+
For more explicit control, the value fed into the hash function used by the router can be directly specified on a per-operation basis using the <code>routing</code> parameter.</p>
|
|
1083
|
+
<p>When setting up explicit mapping, you can also use the <code>_routing</code> field to direct the index operation to extract the routing value from the document itself.
|
|
1084
|
+
This does come at the (very minimal) cost of an additional document parsing pass.
|
|
1085
|
+
If the <code>_routing</code> mapping is defined and set to be required, the index operation will fail if no routing value is provided or extracted.</p>
|
|
1086
|
+
<p>NOTE: Data streams do not support custom routing unless they were created with the <code>allow_custom_routing</code> setting enabled in the template.</p>
|
|
1087
|
+
<p><strong>Distributed</strong></p>
|
|
1088
|
+
<p>The index operation is directed to the primary shard based on its route and performed on the actual node containing this shard.
|
|
1089
|
+
After the primary shard completes the operation, if needed, the update is distributed to applicable replicas.</p>
|
|
1090
|
+
<p><strong>Active shards</strong></p>
|
|
1091
|
+
<p>To improve the resiliency of writes to the system, indexing operations can be configured to wait for a certain number of active shard copies before proceeding with the operation.
|
|
1092
|
+
If the requisite number of active shard copies are not available, then the write operation must wait and retry, until either the requisite shard copies have started or a timeout occurs.
|
|
1093
|
+
By default, write operations only wait for the primary shards to be active before proceeding (that is to say <code>wait_for_active_shards</code> is <code>1</code>).
|
|
1094
|
+
This default can be overridden in the index settings dynamically by setting <code>index.write.wait_for_active_shards</code>.
|
|
1095
|
+
To alter this behavior per operation, use the <code>wait_for_active_shards request</code> parameter.</p>
|
|
1096
|
+
<p>Valid values are all or any positive integer up to the total number of configured copies per shard in the index (which is <code>number_of_replicas</code>+1).
|
|
1097
|
+
Specifying a negative value or a number greater than the number of shard copies will throw an error.</p>
|
|
1098
|
+
<p>For example, suppose you have a cluster of three nodes, A, B, and C and you create an index index with the number of replicas set to 3 (resulting in 4 shard copies, one more copy than there are nodes).
|
|
1099
|
+
If you attempt an indexing operation, by default the operation will only ensure the primary copy of each shard is available before proceeding.
|
|
1100
|
+
This means that even if B and C went down and A hosted the primary shard copies, the indexing operation would still proceed with only one copy of the data.
|
|
1101
|
+
If <code>wait_for_active_shards</code> is set on the request to <code>3</code> (and all three nodes are up), the indexing operation will require 3 active shard copies before proceeding.
|
|
1102
|
+
This requirement should be met because there are 3 active nodes in the cluster, each one holding a copy of the shard.
|
|
1103
|
+
However, if you set <code>wait_for_active_shards</code> to <code>all</code> (or to <code>4</code>, which is the same in this situation), the indexing operation will not proceed as you do not have all 4 copies of each shard active in the index.
|
|
1104
|
+
The operation will timeout unless a new node is brought up in the cluster to host the fourth copy of the shard.</p>
|
|
1105
|
+
<p>It is important to note that this setting greatly reduces the chances of the write operation not writing to the requisite number of shard copies, but it does not completely eliminate the possibility, because this check occurs before the write operation starts.
|
|
1106
|
+
After the write operation is underway, it is still possible for replication to fail on any number of shard copies but still succeed on the primary.
|
|
1107
|
+
The <code>_shards</code> section of the API response reveals the number of shard copies on which replication succeeded and failed.</p>
|
|
1108
|
+
|
|
1109
|
+
|
|
1110
|
+
`<https://www.elastic.co/docs/api/doc/elasticsearch/v9/operation/operation-create>`_
|
|
1111
|
+
|
|
1112
|
+
:param index: The name of the data stream or index to target. If the target doesn't
|
|
1127
1113
|
exist and matches the name or wildcard (`*`) pattern of an index template
|
|
1128
1114
|
with a `data_stream` definition, this request creates the data stream. If
|
|
1129
|
-
the target doesn
|
|
1115
|
+
the target doesn't exist and doesn’t match a data stream template, this request
|
|
1130
1116
|
creates the index.
|
|
1131
|
-
:param id:
|
|
1117
|
+
:param id: A unique identifier for the document. To automatically generate a
|
|
1118
|
+
document ID, use the `POST /<target>/_doc/` request format.
|
|
1132
1119
|
:param document:
|
|
1133
|
-
:param
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
|
|
1120
|
+
:param if_primary_term: Only perform the operation if the document has this primary
|
|
1121
|
+
term.
|
|
1122
|
+
:param if_seq_no: Only perform the operation if the document has this sequence
|
|
1123
|
+
number.
|
|
1124
|
+
:param include_source_on_error: True or false if to include the document source
|
|
1125
|
+
in the error message in case of parsing errors.
|
|
1126
|
+
:param op_type: Set to `create` to only index the document if it does not already
|
|
1127
|
+
exist (put if absent). If a document with the specified `_id` already exists,
|
|
1128
|
+
the indexing operation will fail. The behavior is the same as using the `<index>/_create`
|
|
1129
|
+
endpoint. If a document ID is specified, this paramater defaults to `index`.
|
|
1130
|
+
Otherwise, it defaults to `create`. If the request targets a data stream,
|
|
1131
|
+
an `op_type` of `create` is required.
|
|
1132
|
+
:param pipeline: The ID of the pipeline to use to preprocess incoming documents.
|
|
1133
|
+
If the index has a default ingest pipeline specified, setting the value to
|
|
1134
|
+
`_none` turns off the default ingest pipeline for this request. If a final
|
|
1135
|
+
pipeline is configured, it will always run regardless of the value of this
|
|
1137
1136
|
parameter.
|
|
1138
1137
|
:param refresh: If `true`, Elasticsearch refreshes the affected shards to make
|
|
1139
|
-
this operation visible to search
|
|
1140
|
-
make this operation visible to search
|
|
1141
|
-
|
|
1142
|
-
:param
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1138
|
+
this operation visible to search. If `wait_for`, it waits for a refresh to
|
|
1139
|
+
make this operation visible to search. If `false`, it does nothing with refreshes.
|
|
1140
|
+
:param require_alias: If `true`, the destination must be an index alias.
|
|
1141
|
+
:param require_data_stream: If `true`, the request's actions must target a data
|
|
1142
|
+
stream (existing or to be created).
|
|
1143
|
+
:param routing: A custom value that is used to route operations to a specific
|
|
1144
|
+
shard.
|
|
1145
|
+
:param timeout: The period the request waits for the following operations: automatic
|
|
1146
|
+
index creation, dynamic mapping updates, waiting for active shards. Elasticsearch
|
|
1147
|
+
waits for at least the specified timeout period before failing. The actual
|
|
1148
|
+
wait time could be longer, particularly when multiple waits occur. This parameter
|
|
1149
|
+
is useful for situations where the primary shard assigned to perform the
|
|
1150
|
+
operation might not be available when the operation runs. Some reasons for
|
|
1151
|
+
this might be that the primary shard is currently recovering from a gateway
|
|
1152
|
+
or undergoing relocation. By default, the operation will wait on the primary
|
|
1153
|
+
shard to become available for at least 1 minute before failing and responding
|
|
1154
|
+
with an error. The actual wait time could be longer, particularly when multiple
|
|
1155
|
+
waits occur.
|
|
1156
|
+
:param version: The explicit version number for concurrency control. It must
|
|
1157
|
+
be a non-negative long number.
|
|
1158
|
+
:param version_type: The version type.
|
|
1149
1159
|
:param wait_for_active_shards: The number of shard copies that must be active
|
|
1150
|
-
before proceeding with the operation.
|
|
1151
|
-
up to the total number of shards in the index (`number_of_replicas+1`).
|
|
1160
|
+
before proceeding with the operation. You can set it to `all` or any positive
|
|
1161
|
+
integer up to the total number of shards in the index (`number_of_replicas+1`).
|
|
1162
|
+
The default value of `1` means it waits for each primary shard to be active.
|
|
1152
1163
|
"""
|
|
1153
1164
|
if index in SKIP_IN_PATH:
|
|
1154
1165
|
raise ValueError("Empty value passed for parameter 'index'")
|
|
@@ -1169,12 +1180,24 @@ class AsyncElasticsearch(BaseClient):
|
|
|
1169
1180
|
__query["filter_path"] = filter_path
|
|
1170
1181
|
if human is not None:
|
|
1171
1182
|
__query["human"] = human
|
|
1183
|
+
if if_primary_term is not None:
|
|
1184
|
+
__query["if_primary_term"] = if_primary_term
|
|
1185
|
+
if if_seq_no is not None:
|
|
1186
|
+
__query["if_seq_no"] = if_seq_no
|
|
1187
|
+
if include_source_on_error is not None:
|
|
1188
|
+
__query["include_source_on_error"] = include_source_on_error
|
|
1189
|
+
if op_type is not None:
|
|
1190
|
+
__query["op_type"] = op_type
|
|
1172
1191
|
if pipeline is not None:
|
|
1173
1192
|
__query["pipeline"] = pipeline
|
|
1174
1193
|
if pretty is not None:
|
|
1175
1194
|
__query["pretty"] = pretty
|
|
1176
1195
|
if refresh is not None:
|
|
1177
1196
|
__query["refresh"] = refresh
|
|
1197
|
+
if require_alias is not None:
|
|
1198
|
+
__query["require_alias"] = require_alias
|
|
1199
|
+
if require_data_stream is not None:
|
|
1200
|
+
__query["require_data_stream"] = require_data_stream
|
|
1178
1201
|
if routing is not None:
|
|
1179
1202
|
__query["routing"] = routing
|
|
1180
1203
|
if timeout is not None:
|
|
@@ -1223,29 +1246,60 @@ class AsyncElasticsearch(BaseClient):
|
|
|
1223
1246
|
] = None,
|
|
1224
1247
|
) -> ObjectApiResponse[t.Any]:
|
|
1225
1248
|
"""
|
|
1226
|
-
|
|
1227
|
-
|
|
1228
|
-
|
|
1229
|
-
|
|
1230
|
-
|
|
1231
|
-
|
|
1249
|
+
.. raw:: html
|
|
1250
|
+
|
|
1251
|
+
<p>Delete a document.</p>
|
|
1252
|
+
<p>Remove a JSON document from the specified index.</p>
|
|
1253
|
+
<p>NOTE: You cannot send deletion requests directly to a data stream.
|
|
1254
|
+
To delete a document in a data stream, you must target the backing index containing the document.</p>
|
|
1255
|
+
<p><strong>Optimistic concurrency control</strong></p>
|
|
1256
|
+
<p>Delete operations can be made conditional and only be performed if the last modification to the document was assigned the sequence number and primary term specified by the <code>if_seq_no</code> and <code>if_primary_term</code> parameters.
|
|
1257
|
+
If a mismatch is detected, the operation will result in a <code>VersionConflictException</code> and a status code of <code>409</code>.</p>
|
|
1258
|
+
<p><strong>Versioning</strong></p>
|
|
1259
|
+
<p>Each document indexed is versioned.
|
|
1260
|
+
When deleting a document, the version can be specified to make sure the relevant document you are trying to delete is actually being deleted and it has not changed in the meantime.
|
|
1261
|
+
Every write operation run on a document, deletes included, causes its version to be incremented.
|
|
1262
|
+
The version number of a deleted document remains available for a short time after deletion to allow for control of concurrent operations.
|
|
1263
|
+
The length of time for which a deleted document's version remains available is determined by the <code>index.gc_deletes</code> index setting.</p>
|
|
1264
|
+
<p><strong>Routing</strong></p>
|
|
1265
|
+
<p>If routing is used during indexing, the routing value also needs to be specified to delete a document.</p>
|
|
1266
|
+
<p>If the <code>_routing</code> mapping is set to <code>required</code> and no routing value is specified, the delete API throws a <code>RoutingMissingException</code> and rejects the request.</p>
|
|
1267
|
+
<p>For example:</p>
|
|
1268
|
+
<pre><code>DELETE /my-index-000001/_doc/1?routing=shard-1
|
|
1269
|
+
</code></pre>
|
|
1270
|
+
<p>This request deletes the document with ID 1, but it is routed based on the user.
|
|
1271
|
+
The document is not deleted if the correct routing is not specified.</p>
|
|
1272
|
+
<p><strong>Distributed</strong></p>
|
|
1273
|
+
<p>The delete operation gets hashed into a specific shard ID.
|
|
1274
|
+
It then gets redirected into the primary shard within that ID group and replicated (if needed) to shard replicas within that ID group.</p>
|
|
1275
|
+
|
|
1276
|
+
|
|
1277
|
+
`<https://www.elastic.co/docs/api/doc/elasticsearch/v9/operation/operation-delete>`_
|
|
1278
|
+
|
|
1279
|
+
:param index: The name of the target index.
|
|
1280
|
+
:param id: A unique identifier for the document.
|
|
1232
1281
|
:param if_primary_term: Only perform the operation if the document has this primary
|
|
1233
1282
|
term.
|
|
1234
1283
|
:param if_seq_no: Only perform the operation if the document has this sequence
|
|
1235
1284
|
number.
|
|
1236
1285
|
:param refresh: If `true`, Elasticsearch refreshes the affected shards to make
|
|
1237
|
-
this operation visible to search
|
|
1238
|
-
make this operation visible to search
|
|
1239
|
-
|
|
1240
|
-
:param
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
|
|
1244
|
-
|
|
1245
|
-
|
|
1246
|
-
|
|
1247
|
-
|
|
1248
|
-
|
|
1286
|
+
this operation visible to search. If `wait_for`, it waits for a refresh to
|
|
1287
|
+
make this operation visible to search. If `false`, it does nothing with refreshes.
|
|
1288
|
+
:param routing: A custom value used to route operations to a specific shard.
|
|
1289
|
+
:param timeout: The period to wait for active shards. This parameter is useful
|
|
1290
|
+
for situations where the primary shard assigned to perform the delete operation
|
|
1291
|
+
might not be available when the delete operation runs. Some reasons for this
|
|
1292
|
+
might be that the primary shard is currently recovering from a store or undergoing
|
|
1293
|
+
relocation. By default, the delete operation will wait on the primary shard
|
|
1294
|
+
to become available for up to 1 minute before failing and responding with
|
|
1295
|
+
an error.
|
|
1296
|
+
:param version: An explicit version number for concurrency control. It must match
|
|
1297
|
+
the current version of the document for the request to succeed.
|
|
1298
|
+
:param version_type: The version type.
|
|
1299
|
+
:param wait_for_active_shards: The minimum number of shard copies that must be
|
|
1300
|
+
active before proceeding with the operation. You can set it to `all` or any
|
|
1301
|
+
positive integer up to the total number of shards in the index (`number_of_replicas+1`).
|
|
1302
|
+
The default value of `1` means it waits for each primary shard to be active.
|
|
1249
1303
|
"""
|
|
1250
1304
|
if index in SKIP_IN_PATH:
|
|
1251
1305
|
raise ValueError("Empty value passed for parameter 'index'")
|
|
@@ -1345,72 +1399,148 @@ class AsyncElasticsearch(BaseClient):
|
|
|
1345
1399
|
body: t.Optional[t.Dict[str, t.Any]] = None,
|
|
1346
1400
|
) -> ObjectApiResponse[t.Any]:
|
|
1347
1401
|
"""
|
|
1348
|
-
|
|
1349
|
-
|
|
1350
|
-
|
|
1402
|
+
.. raw:: html
|
|
1403
|
+
|
|
1404
|
+
<p>Delete documents.</p>
|
|
1405
|
+
<p>Deletes documents that match the specified query.</p>
|
|
1406
|
+
<p>If the Elasticsearch security features are enabled, you must have the following index privileges for the target data stream, index, or alias:</p>
|
|
1407
|
+
<ul>
|
|
1408
|
+
<li><code>read</code></li>
|
|
1409
|
+
<li><code>delete</code> or <code>write</code></li>
|
|
1410
|
+
</ul>
|
|
1411
|
+
<p>You can specify the query criteria in the request URI or the request body using the same syntax as the search API.
|
|
1412
|
+
When you submit a delete by query request, Elasticsearch gets a snapshot of the data stream or index when it begins processing the request and deletes matching documents using internal versioning.
|
|
1413
|
+
If a document changes between the time that the snapshot is taken and the delete operation is processed, it results in a version conflict and the delete operation fails.</p>
|
|
1414
|
+
<p>NOTE: Documents with a version equal to 0 cannot be deleted using delete by query because internal versioning does not support 0 as a valid version number.</p>
|
|
1415
|
+
<p>While processing a delete by query request, Elasticsearch performs multiple search requests sequentially to find all of the matching documents to delete.
|
|
1416
|
+
A bulk delete request is performed for each batch of matching documents.
|
|
1417
|
+
If a search or bulk request is rejected, the requests are retried up to 10 times, with exponential back off.
|
|
1418
|
+
If the maximum retry limit is reached, processing halts and all failed requests are returned in the response.
|
|
1419
|
+
Any delete requests that completed successfully still stick, they are not rolled back.</p>
|
|
1420
|
+
<p>You can opt to count version conflicts instead of halting and returning by setting <code>conflicts</code> to <code>proceed</code>.
|
|
1421
|
+
Note that if you opt to count version conflicts the operation could attempt to delete more documents from the source than <code>max_docs</code> until it has successfully deleted <code>max_docs documents</code>, or it has gone through every document in the source query.</p>
|
|
1422
|
+
<p><strong>Throttling delete requests</strong></p>
|
|
1423
|
+
<p>To control the rate at which delete by query issues batches of delete operations, you can set <code>requests_per_second</code> to any positive decimal number.
|
|
1424
|
+
This pads each batch with a wait time to throttle the rate.
|
|
1425
|
+
Set <code>requests_per_second</code> to <code>-1</code> to disable throttling.</p>
|
|
1426
|
+
<p>Throttling uses a wait time between batches so that the internal scroll requests can be given a timeout that takes the request padding into account.
|
|
1427
|
+
The padding time is the difference between the batch size divided by the <code>requests_per_second</code> and the time spent writing.
|
|
1428
|
+
By default the batch size is <code>1000</code>, so if <code>requests_per_second</code> is set to <code>500</code>:</p>
|
|
1429
|
+
<pre><code>target_time = 1000 / 500 per second = 2 seconds
|
|
1430
|
+
wait_time = target_time - write_time = 2 seconds - .5 seconds = 1.5 seconds
|
|
1431
|
+
</code></pre>
|
|
1432
|
+
<p>Since the batch is issued as a single <code>_bulk</code> request, large batch sizes cause Elasticsearch to create many requests and wait before starting the next set.
|
|
1433
|
+
This is "bursty" instead of "smooth".</p>
|
|
1434
|
+
<p><strong>Slicing</strong></p>
|
|
1435
|
+
<p>Delete by query supports sliced scroll to parallelize the delete process.
|
|
1436
|
+
This can improve efficiency and provide a convenient way to break the request down into smaller parts.</p>
|
|
1437
|
+
<p>Setting <code>slices</code> to <code>auto</code> lets Elasticsearch choose the number of slices to use.
|
|
1438
|
+
This setting will use one slice per shard, up to a certain limit.
|
|
1439
|
+
If there are multiple source data streams or indices, it will choose the number of slices based on the index or backing index with the smallest number of shards.
|
|
1440
|
+
Adding slices to the delete by query operation creates sub-requests which means it has some quirks:</p>
|
|
1441
|
+
<ul>
|
|
1442
|
+
<li>You can see these requests in the tasks APIs. These sub-requests are "child" tasks of the task for the request with slices.</li>
|
|
1443
|
+
<li>Fetching the status of the task for the request with slices only contains the status of completed slices.</li>
|
|
1444
|
+
<li>These sub-requests are individually addressable for things like cancellation and rethrottling.</li>
|
|
1445
|
+
<li>Rethrottling the request with <code>slices</code> will rethrottle the unfinished sub-request proportionally.</li>
|
|
1446
|
+
<li>Canceling the request with <code>slices</code> will cancel each sub-request.</li>
|
|
1447
|
+
<li>Due to the nature of <code>slices</code> each sub-request won't get a perfectly even portion of the documents. All documents will be addressed, but some slices may be larger than others. Expect larger slices to have a more even distribution.</li>
|
|
1448
|
+
<li>Parameters like <code>requests_per_second</code> and <code>max_docs</code> on a request with <code>slices</code> are distributed proportionally to each sub-request. Combine that with the earlier point about distribution being uneven and you should conclude that using <code>max_docs</code> with <code>slices</code> might not result in exactly <code>max_docs</code> documents being deleted.</li>
|
|
1449
|
+
<li>Each sub-request gets a slightly different snapshot of the source data stream or index though these are all taken at approximately the same time.</li>
|
|
1450
|
+
</ul>
|
|
1451
|
+
<p>If you're slicing manually or otherwise tuning automatic slicing, keep in mind that:</p>
|
|
1452
|
+
<ul>
|
|
1453
|
+
<li>Query performance is most efficient when the number of slices is equal to the number of shards in the index or backing index. If that number is large (for example, 500), choose a lower number as too many <code>slices</code> hurts performance. Setting <code>slices</code> higher than the number of shards generally does not improve efficiency and adds overhead.</li>
|
|
1454
|
+
<li>Delete performance scales linearly across available resources with the number of slices.</li>
|
|
1455
|
+
</ul>
|
|
1456
|
+
<p>Whether query or delete performance dominates the runtime depends on the documents being reindexed and cluster resources.</p>
|
|
1457
|
+
<p><strong>Cancel a delete by query operation</strong></p>
|
|
1458
|
+
<p>Any delete by query can be canceled using the task cancel API. For example:</p>
|
|
1459
|
+
<pre><code>POST _tasks/r1A2WoRbTwKZ516z6NEs5A:36619/_cancel
|
|
1460
|
+
</code></pre>
|
|
1461
|
+
<p>The task ID can be found by using the get tasks API.</p>
|
|
1462
|
+
<p>Cancellation should happen quickly but might take a few seconds.
|
|
1463
|
+
The get task status API will continue to list the delete by query task until this task checks that it has been cancelled and terminates itself.</p>
|
|
1464
|
+
|
|
1465
|
+
|
|
1466
|
+
`<https://www.elastic.co/docs/api/doc/elasticsearch/v9/operation/operation-delete-by-query>`_
|
|
1351
1467
|
|
|
1352
|
-
:param index:
|
|
1353
|
-
|
|
1354
|
-
parameter or use `*` or `_all`.
|
|
1468
|
+
:param index: A comma-separated list of data streams, indices, and aliases to
|
|
1469
|
+
search. It supports wildcards (`*`). To search all data streams or indices,
|
|
1470
|
+
omit this parameter or use `*` or `_all`.
|
|
1355
1471
|
:param allow_no_indices: If `false`, the request returns an error if any wildcard
|
|
1356
1472
|
expression, index alias, or `_all` value targets only missing or closed indices.
|
|
1357
1473
|
This behavior applies even if the request targets other open indices. For
|
|
1358
1474
|
example, a request targeting `foo*,bar*` returns an error if an index starts
|
|
1359
1475
|
with `foo` but no index starts with `bar`.
|
|
1360
1476
|
:param analyze_wildcard: If `true`, wildcard and prefix queries are analyzed.
|
|
1361
|
-
|
|
1477
|
+
This parameter can be used only when the `q` query string parameter is specified.
|
|
1478
|
+
:param analyzer: Analyzer to use for the query string. This parameter can be
|
|
1479
|
+
used only when the `q` query string parameter is specified.
|
|
1362
1480
|
:param conflicts: What to do if delete by query hits version conflicts: `abort`
|
|
1363
1481
|
or `proceed`.
|
|
1364
1482
|
:param default_operator: The default operator for query string query: `AND` or
|
|
1365
|
-
`OR`.
|
|
1366
|
-
|
|
1367
|
-
|
|
1368
|
-
|
|
1369
|
-
|
|
1370
|
-
|
|
1371
|
-
|
|
1372
|
-
|
|
1483
|
+
`OR`. This parameter can be used only when the `q` query string parameter
|
|
1484
|
+
is specified.
|
|
1485
|
+
:param df: The field to use as default where no field prefix is given in the
|
|
1486
|
+
query string. This parameter can be used only when the `q` query string parameter
|
|
1487
|
+
is specified.
|
|
1488
|
+
:param expand_wildcards: The type of index that wildcard patterns can match.
|
|
1489
|
+
If the request can target data streams, this argument determines whether
|
|
1490
|
+
wildcard expressions match hidden data streams. It supports comma-separated
|
|
1491
|
+
values, such as `open,hidden`.
|
|
1492
|
+
:param from_: Skips the specified number of documents.
|
|
1373
1493
|
:param ignore_unavailable: If `false`, the request returns an error if it targets
|
|
1374
1494
|
a missing or closed index.
|
|
1375
1495
|
:param lenient: If `true`, format-based query failures (such as providing text
|
|
1376
|
-
to a numeric field) in the query string will be ignored.
|
|
1496
|
+
to a numeric field) in the query string will be ignored. This parameter can
|
|
1497
|
+
be used only when the `q` query string parameter is specified.
|
|
1377
1498
|
:param max_docs: The maximum number of documents to delete.
|
|
1378
|
-
:param preference:
|
|
1379
|
-
|
|
1380
|
-
:param q:
|
|
1381
|
-
:param query:
|
|
1499
|
+
:param preference: The node or shard the operation should be performed on. It
|
|
1500
|
+
is random by default.
|
|
1501
|
+
:param q: A query in the Lucene query string syntax.
|
|
1502
|
+
:param query: The documents to delete specified with Query DSL.
|
|
1382
1503
|
:param refresh: If `true`, Elasticsearch refreshes all shards involved in the
|
|
1383
|
-
delete by query after the request completes.
|
|
1504
|
+
delete by query after the request completes. This is different than the delete
|
|
1505
|
+
API's `refresh` parameter, which causes just the shard that received the
|
|
1506
|
+
delete request to be refreshed. Unlike the delete API, it does not support
|
|
1507
|
+
`wait_for`.
|
|
1384
1508
|
:param request_cache: If `true`, the request cache is used for this request.
|
|
1385
1509
|
Defaults to the index-level setting.
|
|
1386
1510
|
:param requests_per_second: The throttle for this request in sub-requests per
|
|
1387
1511
|
second.
|
|
1388
|
-
:param routing:
|
|
1389
|
-
:param scroll:
|
|
1390
|
-
:param scroll_size:
|
|
1391
|
-
:param search_timeout:
|
|
1392
|
-
no timeout.
|
|
1393
|
-
:param search_type: The type of the search operation. Available options
|
|
1394
|
-
`dfs_query_then_fetch`.
|
|
1512
|
+
:param routing: A custom value used to route operations to a specific shard.
|
|
1513
|
+
:param scroll: The period to retain the search context for scrolling.
|
|
1514
|
+
:param scroll_size: The size of the scroll request that powers the operation.
|
|
1515
|
+
:param search_timeout: The explicit timeout for each search request. It defaults
|
|
1516
|
+
to no timeout.
|
|
1517
|
+
:param search_type: The type of the search operation. Available options include
|
|
1518
|
+
`query_then_fetch` and `dfs_query_then_fetch`.
|
|
1395
1519
|
:param slice: Slice the request manually using the provided slice ID and total
|
|
1396
1520
|
number of slices.
|
|
1397
1521
|
:param slices: The number of slices this task should be divided into.
|
|
1398
|
-
:param sort: A comma-separated list of
|
|
1399
|
-
:param stats:
|
|
1400
|
-
:param terminate_after:
|
|
1522
|
+
:param sort: A comma-separated list of `<field>:<direction>` pairs.
|
|
1523
|
+
:param stats: The specific `tag` of the request for logging and statistical purposes.
|
|
1524
|
+
:param terminate_after: The maximum number of documents to collect for each shard.
|
|
1401
1525
|
If a query reaches this limit, Elasticsearch terminates the query early.
|
|
1402
1526
|
Elasticsearch collects documents before sorting. Use with caution. Elasticsearch
|
|
1403
1527
|
applies this parameter to each shard handling the request. When possible,
|
|
1404
1528
|
let Elasticsearch perform early termination automatically. Avoid specifying
|
|
1405
1529
|
this parameter for requests that target data streams with backing indices
|
|
1406
1530
|
across multiple data tiers.
|
|
1407
|
-
:param timeout:
|
|
1531
|
+
:param timeout: The period each deletion request waits for active shards.
|
|
1408
1532
|
:param version: If `true`, returns the document version as part of a hit.
|
|
1409
1533
|
:param wait_for_active_shards: The number of shard copies that must be active
|
|
1410
|
-
before proceeding with the operation. Set to all or any positive integer
|
|
1411
|
-
up to the total number of shards in the index (`number_of_replicas+1`).
|
|
1534
|
+
before proceeding with the operation. Set to `all` or any positive integer
|
|
1535
|
+
up to the total number of shards in the index (`number_of_replicas+1`). The
|
|
1536
|
+
`timeout` value controls how long each write request waits for unavailable
|
|
1537
|
+
shards to become available.
|
|
1412
1538
|
:param wait_for_completion: If `true`, the request blocks until the operation
|
|
1413
|
-
is complete.
|
|
1539
|
+
is complete. If `false`, Elasticsearch performs some preflight checks, launches
|
|
1540
|
+
the request, and returns a task you can use to cancel or get the status of
|
|
1541
|
+
the task. Elasticsearch creates a record of this task as a document at `.tasks/task/${taskId}`.
|
|
1542
|
+
When you are done with a task, you should delete the task document so Elasticsearch
|
|
1543
|
+
can reclaim the space.
|
|
1414
1544
|
"""
|
|
1415
1545
|
if index in SKIP_IN_PATH:
|
|
1416
1546
|
raise ValueError("Empty value passed for parameter 'index'")
|
|
@@ -1523,16 +1653,18 @@ class AsyncElasticsearch(BaseClient):
|
|
|
1523
1653
|
requests_per_second: t.Optional[float] = None,
|
|
1524
1654
|
) -> ObjectApiResponse[t.Any]:
|
|
1525
1655
|
"""
|
|
1526
|
-
|
|
1527
|
-
|
|
1528
|
-
|
|
1529
|
-
|
|
1656
|
+
.. raw:: html
|
|
1657
|
+
|
|
1658
|
+
<p>Throttle a delete by query operation.</p>
|
|
1659
|
+
<p>Change the number of requests per second for a particular delete by query operation.
|
|
1660
|
+
Rethrottling that speeds up the query takes effect immediately but rethrotting that slows down the query takes effect after completing the current batch to prevent scroll timeouts.</p>
|
|
1530
1661
|
|
|
1531
|
-
|
|
1662
|
+
|
|
1663
|
+
`<https://www.elastic.co/docs/api/doc/elasticsearch/v9/operation/operation-delete-by-query-rethrottle>`_
|
|
1532
1664
|
|
|
1533
1665
|
:param task_id: The ID for the task.
|
|
1534
1666
|
:param requests_per_second: The throttle for this request in sub-requests per
|
|
1535
|
-
second.
|
|
1667
|
+
second. To disable throttling, set it to `-1`.
|
|
1536
1668
|
"""
|
|
1537
1669
|
if task_id in SKIP_IN_PATH:
|
|
1538
1670
|
raise ValueError("Empty value passed for parameter 'task_id'")
|
|
@@ -1572,16 +1704,22 @@ class AsyncElasticsearch(BaseClient):
|
|
|
1572
1704
|
timeout: t.Optional[t.Union[str, t.Literal[-1], t.Literal[0]]] = None,
|
|
1573
1705
|
) -> ObjectApiResponse[t.Any]:
|
|
1574
1706
|
"""
|
|
1575
|
-
|
|
1707
|
+
.. raw:: html
|
|
1576
1708
|
|
|
1577
|
-
|
|
1709
|
+
<p>Delete a script or search template.
|
|
1710
|
+
Deletes a stored script or search template.</p>
|
|
1578
1711
|
|
|
1579
|
-
|
|
1580
|
-
|
|
1581
|
-
|
|
1582
|
-
|
|
1583
|
-
:param
|
|
1584
|
-
the timeout expires, the request fails
|
|
1712
|
+
|
|
1713
|
+
`<https://www.elastic.co/docs/api/doc/elasticsearch/v9/operation/operation-delete-script>`_
|
|
1714
|
+
|
|
1715
|
+
:param id: The identifier for the stored script or search template.
|
|
1716
|
+
:param master_timeout: The period to wait for a connection to the master node.
|
|
1717
|
+
If no response is received before the timeout expires, the request fails
|
|
1718
|
+
and returns an error. It can also be set to `-1` to indicate that the request
|
|
1719
|
+
should never timeout.
|
|
1720
|
+
:param timeout: The period to wait for a response. If no response is received
|
|
1721
|
+
before the timeout expires, the request fails and returns an error. It can
|
|
1722
|
+
also be set to `-1` to indicate that the request should never timeout.
|
|
1585
1723
|
"""
|
|
1586
1724
|
if id in SKIP_IN_PATH:
|
|
1587
1725
|
raise ValueError("Empty value passed for parameter 'id'")
|
|
@@ -1640,32 +1778,60 @@ class AsyncElasticsearch(BaseClient):
|
|
|
1640
1778
|
] = None,
|
|
1641
1779
|
) -> HeadApiResponse:
|
|
1642
1780
|
"""
|
|
1643
|
-
|
|
1644
|
-
|
|
1645
|
-
|
|
1646
|
-
|
|
1647
|
-
|
|
1648
|
-
|
|
1649
|
-
|
|
1650
|
-
|
|
1651
|
-
|
|
1781
|
+
.. raw:: html
|
|
1782
|
+
|
|
1783
|
+
<p>Check a document.</p>
|
|
1784
|
+
<p>Verify that a document exists.
|
|
1785
|
+
For example, check to see if a document with the <code>_id</code> 0 exists:</p>
|
|
1786
|
+
<pre><code>HEAD my-index-000001/_doc/0
|
|
1787
|
+
</code></pre>
|
|
1788
|
+
<p>If the document exists, the API returns a status code of <code>200 - OK</code>.
|
|
1789
|
+
If the document doesn’t exist, the API returns <code>404 - Not Found</code>.</p>
|
|
1790
|
+
<p><strong>Versioning support</strong></p>
|
|
1791
|
+
<p>You can use the <code>version</code> parameter to check the document only if its current version is equal to the specified one.</p>
|
|
1792
|
+
<p>Internally, Elasticsearch has marked the old document as deleted and added an entirely new document.
|
|
1793
|
+
The old version of the document doesn't disappear immediately, although you won't be able to access it.
|
|
1794
|
+
Elasticsearch cleans up deleted documents in the background as you continue to index more data.</p>
|
|
1795
|
+
|
|
1796
|
+
|
|
1797
|
+
`<https://www.elastic.co/docs/api/doc/elasticsearch/v9/operation/operation-get>`_
|
|
1798
|
+
|
|
1799
|
+
:param index: A comma-separated list of data streams, indices, and aliases. It
|
|
1800
|
+
supports wildcards (`*`).
|
|
1801
|
+
:param id: A unique document identifier.
|
|
1802
|
+
:param preference: The node or shard the operation should be performed on. By
|
|
1803
|
+
default, the operation is randomized between the shard replicas. If it is
|
|
1804
|
+
set to `_local`, the operation will prefer to be run on a local allocated
|
|
1805
|
+
shard when possible. If it is set to a custom value, the value is used to
|
|
1806
|
+
guarantee that the same shards will be used for the same custom value. This
|
|
1807
|
+
can help with "jumping values" when hitting different shards in different
|
|
1808
|
+
refresh states. A sample value can be something like the web session ID or
|
|
1809
|
+
the user name.
|
|
1652
1810
|
:param realtime: If `true`, the request is real-time as opposed to near-real-time.
|
|
1653
|
-
:param refresh: If `true`,
|
|
1654
|
-
|
|
1655
|
-
|
|
1656
|
-
|
|
1657
|
-
|
|
1658
|
-
:param
|
|
1659
|
-
the
|
|
1811
|
+
:param refresh: If `true`, the request refreshes the relevant shards before retrieving
|
|
1812
|
+
the document. Setting it to `true` should be done after careful thought and
|
|
1813
|
+
verification that this does not cause a heavy load on the system (and slow
|
|
1814
|
+
down indexing).
|
|
1815
|
+
:param routing: A custom value used to route operations to a specific shard.
|
|
1816
|
+
:param source: Indicates whether to return the `_source` field (`true` or `false`)
|
|
1817
|
+
or lists the fields to return.
|
|
1818
|
+
:param source_excludes: A comma-separated list of source fields to exclude from
|
|
1819
|
+
the response. You can also use this parameter to exclude fields from the
|
|
1820
|
+
subset specified in `_source_includes` query parameter. If the `_source`
|
|
1821
|
+
parameter is `false`, this parameter is ignored.
|
|
1660
1822
|
:param source_includes: A comma-separated list of source fields to include in
|
|
1661
|
-
the response.
|
|
1662
|
-
|
|
1663
|
-
|
|
1664
|
-
|
|
1823
|
+
the response. If this parameter is specified, only these source fields are
|
|
1824
|
+
returned. You can exclude fields from this subset using the `_source_excludes`
|
|
1825
|
+
query parameter. If the `_source` parameter is `false`, this parameter is
|
|
1826
|
+
ignored.
|
|
1827
|
+
:param stored_fields: A comma-separated list of stored fields to return as part
|
|
1828
|
+
of a hit. If no fields are specified, no stored fields are included in the
|
|
1829
|
+
response. If this field is specified, the `_source` parameter defaults to
|
|
1830
|
+
`false`.
|
|
1665
1831
|
:param version: Explicit version number for concurrency control. The specified
|
|
1666
1832
|
version must match the current version of the document for the request to
|
|
1667
1833
|
succeed.
|
|
1668
|
-
:param version_type:
|
|
1834
|
+
:param version_type: The version type.
|
|
1669
1835
|
"""
|
|
1670
1836
|
if index in SKIP_IN_PATH:
|
|
1671
1837
|
raise ValueError("Empty value passed for parameter 'index'")
|
|
@@ -1741,29 +1907,38 @@ class AsyncElasticsearch(BaseClient):
|
|
|
1741
1907
|
] = None,
|
|
1742
1908
|
) -> HeadApiResponse:
|
|
1743
1909
|
"""
|
|
1744
|
-
|
|
1910
|
+
.. raw:: html
|
|
1745
1911
|
|
|
1746
|
-
|
|
1912
|
+
<p>Check for a document source.</p>
|
|
1913
|
+
<p>Check whether a document source exists in an index.
|
|
1914
|
+
For example:</p>
|
|
1915
|
+
<pre><code>HEAD my-index-000001/_source/1
|
|
1916
|
+
</code></pre>
|
|
1917
|
+
<p>A document's source is not available if it is disabled in the mapping.</p>
|
|
1747
1918
|
|
|
1748
|
-
|
|
1749
|
-
|
|
1750
|
-
|
|
1751
|
-
:param
|
|
1752
|
-
|
|
1753
|
-
:param
|
|
1754
|
-
:param
|
|
1755
|
-
|
|
1756
|
-
:param
|
|
1757
|
-
:param
|
|
1758
|
-
|
|
1919
|
+
|
|
1920
|
+
`<https://www.elastic.co/docs/api/doc/elasticsearch/v9/operation/operation-get>`_
|
|
1921
|
+
|
|
1922
|
+
:param index: A comma-separated list of data streams, indices, and aliases. It
|
|
1923
|
+
supports wildcards (`*`).
|
|
1924
|
+
:param id: A unique identifier for the document.
|
|
1925
|
+
:param preference: The node or shard the operation should be performed on. By
|
|
1926
|
+
default, the operation is randomized between the shard replicas.
|
|
1927
|
+
:param realtime: If `true`, the request is real-time as opposed to near-real-time.
|
|
1928
|
+
:param refresh: If `true`, the request refreshes the relevant shards before retrieving
|
|
1929
|
+
the document. Setting it to `true` should be done after careful thought and
|
|
1930
|
+
verification that this does not cause a heavy load on the system (and slow
|
|
1931
|
+
down indexing).
|
|
1932
|
+
:param routing: A custom value used to route operations to a specific shard.
|
|
1933
|
+
:param source: Indicates whether to return the `_source` field (`true` or `false`)
|
|
1934
|
+
or lists the fields to return.
|
|
1759
1935
|
:param source_excludes: A comma-separated list of source fields to exclude in
|
|
1760
1936
|
the response.
|
|
1761
1937
|
:param source_includes: A comma-separated list of source fields to include in
|
|
1762
1938
|
the response.
|
|
1763
|
-
:param version:
|
|
1764
|
-
|
|
1765
|
-
|
|
1766
|
-
:param version_type: Specific version type: `external`, `external_gte`.
|
|
1939
|
+
:param version: The version number for concurrency control. It must match the
|
|
1940
|
+
current version of the document for the request to succeed.
|
|
1941
|
+
:param version_type: The version type.
|
|
1767
1942
|
"""
|
|
1768
1943
|
if index in SKIP_IN_PATH:
|
|
1769
1944
|
raise ValueError("Empty value passed for parameter 'index'")
|
|
@@ -1841,34 +2016,47 @@ class AsyncElasticsearch(BaseClient):
|
|
|
1841
2016
|
body: t.Optional[t.Dict[str, t.Any]] = None,
|
|
1842
2017
|
) -> ObjectApiResponse[t.Any]:
|
|
1843
2018
|
"""
|
|
1844
|
-
|
|
1845
|
-
|
|
2019
|
+
.. raw:: html
|
|
2020
|
+
|
|
2021
|
+
<p>Explain a document match result.
|
|
2022
|
+
Get information about why a specific document matches, or doesn't match, a query.
|
|
2023
|
+
It computes a score explanation for a query and a specific document.</p>
|
|
2024
|
+
|
|
1846
2025
|
|
|
1847
|
-
`<https://www.elastic.co/
|
|
2026
|
+
`<https://www.elastic.co/docs/api/doc/elasticsearch/v9/operation/operation-explain>`_
|
|
1848
2027
|
|
|
1849
|
-
:param index: Index names used to limit the request. Only a single index
|
|
1850
|
-
can be provided to this parameter.
|
|
1851
|
-
:param id:
|
|
2028
|
+
:param index: Index names that are used to limit the request. Only a single index
|
|
2029
|
+
name can be provided to this parameter.
|
|
2030
|
+
:param id: The document identifier.
|
|
1852
2031
|
:param analyze_wildcard: If `true`, wildcard and prefix queries are analyzed.
|
|
1853
|
-
|
|
1854
|
-
|
|
2032
|
+
This parameter can be used only when the `q` query string parameter is specified.
|
|
2033
|
+
:param analyzer: The analyzer to use for the query string. This parameter can
|
|
2034
|
+
be used only when the `q` query string parameter is specified.
|
|
1855
2035
|
:param default_operator: The default operator for query string query: `AND` or
|
|
1856
|
-
`OR`.
|
|
1857
|
-
|
|
1858
|
-
|
|
2036
|
+
`OR`. This parameter can be used only when the `q` query string parameter
|
|
2037
|
+
is specified.
|
|
2038
|
+
:param df: The field to use as default where no field prefix is given in the
|
|
2039
|
+
query string. This parameter can be used only when the `q` query string parameter
|
|
2040
|
+
is specified.
|
|
1859
2041
|
:param lenient: If `true`, format-based query failures (such as providing text
|
|
1860
|
-
to a numeric field) in the query string will be ignored.
|
|
1861
|
-
|
|
1862
|
-
|
|
1863
|
-
|
|
2042
|
+
to a numeric field) in the query string will be ignored. This parameter can
|
|
2043
|
+
be used only when the `q` query string parameter is specified.
|
|
2044
|
+
:param preference: The node or shard the operation should be performed on. It
|
|
2045
|
+
is random by default.
|
|
2046
|
+
:param q: The query in the Lucene query string syntax.
|
|
1864
2047
|
:param query: Defines the search definition using the Query DSL.
|
|
1865
|
-
:param routing:
|
|
1866
|
-
:param source: True or false to return the `_source` field or not
|
|
2048
|
+
:param routing: A custom value used to route operations to a specific shard.
|
|
2049
|
+
:param source: `True` or `false` to return the `_source` field or not or a list
|
|
1867
2050
|
of fields to return.
|
|
1868
2051
|
:param source_excludes: A comma-separated list of source fields to exclude from
|
|
1869
|
-
the response.
|
|
2052
|
+
the response. You can also use this parameter to exclude fields from the
|
|
2053
|
+
subset specified in `_source_includes` query parameter. If the `_source`
|
|
2054
|
+
parameter is `false`, this parameter is ignored.
|
|
1870
2055
|
:param source_includes: A comma-separated list of source fields to include in
|
|
1871
|
-
the response.
|
|
2056
|
+
the response. If this parameter is specified, only these source fields are
|
|
2057
|
+
returned. You can exclude fields from this subset using the `_source_excludes`
|
|
2058
|
+
query parameter. If the `_source` parameter is `false`, this parameter is
|
|
2059
|
+
ignored.
|
|
1872
2060
|
:param stored_fields: A comma-separated list of stored fields to return in the
|
|
1873
2061
|
response.
|
|
1874
2062
|
"""
|
|
@@ -1961,15 +2149,18 @@ class AsyncElasticsearch(BaseClient):
|
|
|
1961
2149
|
body: t.Optional[t.Dict[str, t.Any]] = None,
|
|
1962
2150
|
) -> ObjectApiResponse[t.Any]:
|
|
1963
2151
|
"""
|
|
1964
|
-
|
|
1965
|
-
|
|
1966
|
-
|
|
1967
|
-
|
|
1968
|
-
|
|
2152
|
+
.. raw:: html
|
|
2153
|
+
|
|
2154
|
+
<p>Get the field capabilities.</p>
|
|
2155
|
+
<p>Get information about the capabilities of fields among multiple indices.</p>
|
|
2156
|
+
<p>For data streams, the API returns field capabilities among the stream’s backing indices.
|
|
2157
|
+
It returns runtime fields like any other field.
|
|
2158
|
+
For example, a runtime field with a type of keyword is returned the same as any other field that belongs to the <code>keyword</code> family.</p>
|
|
2159
|
+
|
|
1969
2160
|
|
|
1970
|
-
`<https://www.elastic.co/
|
|
2161
|
+
`<https://www.elastic.co/docs/api/doc/elasticsearch/v9/operation/operation-field-caps>`_
|
|
1971
2162
|
|
|
1972
|
-
:param index:
|
|
2163
|
+
:param index: A comma-separated list of data streams, indices, and aliases used
|
|
1973
2164
|
to limit the request. Supports wildcards (*). To target all data streams
|
|
1974
2165
|
and indices, omit this parameter or use * or _all.
|
|
1975
2166
|
:param allow_no_indices: If false, the request returns an error if any wildcard
|
|
@@ -1977,25 +2168,32 @@ class AsyncElasticsearch(BaseClient):
|
|
|
1977
2168
|
This behavior applies even if the request targets other open indices. For
|
|
1978
2169
|
example, a request targeting `foo*,bar*` returns an error if an index starts
|
|
1979
2170
|
with foo but no index starts with bar.
|
|
1980
|
-
:param expand_wildcards:
|
|
1981
|
-
request can target data streams, this argument determines whether
|
|
1982
|
-
expressions match hidden data streams. Supports comma-separated
|
|
1983
|
-
as `open,hidden`.
|
|
1984
|
-
:param fields:
|
|
1985
|
-
are supported.
|
|
1986
|
-
:param filters:
|
|
2171
|
+
:param expand_wildcards: The type of index that wildcard patterns can match.
|
|
2172
|
+
If the request can target data streams, this argument determines whether
|
|
2173
|
+
wildcard expressions match hidden data streams. Supports comma-separated
|
|
2174
|
+
values, such as `open,hidden`.
|
|
2175
|
+
:param fields: A list of fields to retrieve capabilities for. Wildcard (`*`)
|
|
2176
|
+
expressions are supported.
|
|
2177
|
+
:param filters: A comma-separated list of filters to apply to the response.
|
|
1987
2178
|
:param ignore_unavailable: If `true`, missing or closed indices are not included
|
|
1988
2179
|
in the response.
|
|
1989
2180
|
:param include_empty_fields: If false, empty fields are not included in the response.
|
|
1990
2181
|
:param include_unmapped: If true, unmapped fields are included in the response.
|
|
1991
|
-
:param index_filter:
|
|
1992
|
-
|
|
1993
|
-
|
|
2182
|
+
:param index_filter: Filter indices if the provided query rewrites to `match_none`
|
|
2183
|
+
on every shard. IMPORTANT: The filtering is done on a best-effort basis,
|
|
2184
|
+
it uses index statistics and mappings to rewrite queries to `match_none`
|
|
2185
|
+
instead of fully running the request. For instance a range query over a date
|
|
2186
|
+
field can rewrite to `match_none` if all documents within a shard (including
|
|
2187
|
+
deleted documents) are outside of the provided range. However, not all queries
|
|
2188
|
+
can rewrite to `match_none` so this API may return an index even if the provided
|
|
2189
|
+
filter matches no document.
|
|
2190
|
+
:param runtime_mappings: Define ad-hoc runtime fields in the request similar
|
|
1994
2191
|
to the way it is done in search requests. These fields exist only as part
|
|
1995
2192
|
of the query and take precedence over fields defined with the same name in
|
|
1996
2193
|
the index mappings.
|
|
1997
|
-
:param types:
|
|
1998
|
-
|
|
2194
|
+
:param types: A comma-separated list of field types to include. Any fields that
|
|
2195
|
+
do not match one of these types will be excluded from the results. It defaults
|
|
2196
|
+
to empty, meaning that all field types are returned.
|
|
1999
2197
|
"""
|
|
2000
2198
|
__path_parts: t.Dict[str, str]
|
|
2001
2199
|
if index not in SKIP_IN_PATH:
|
|
@@ -2081,36 +2279,87 @@ class AsyncElasticsearch(BaseClient):
|
|
|
2081
2279
|
] = None,
|
|
2082
2280
|
) -> ObjectApiResponse[t.Any]:
|
|
2083
2281
|
"""
|
|
2084
|
-
|
|
2085
|
-
|
|
2086
|
-
|
|
2087
|
-
|
|
2088
|
-
|
|
2089
|
-
|
|
2090
|
-
|
|
2091
|
-
|
|
2092
|
-
|
|
2093
|
-
|
|
2094
|
-
|
|
2095
|
-
|
|
2096
|
-
|
|
2282
|
+
.. raw:: html
|
|
2283
|
+
|
|
2284
|
+
<p>Get a document by its ID.</p>
|
|
2285
|
+
<p>Get a document and its source or stored fields from an index.</p>
|
|
2286
|
+
<p>By default, this API is realtime and is not affected by the refresh rate of the index (when data will become visible for search).
|
|
2287
|
+
In the case where stored fields are requested with the <code>stored_fields</code> parameter and the document has been updated but is not yet refreshed, the API will have to parse and analyze the source to extract the stored fields.
|
|
2288
|
+
To turn off realtime behavior, set the <code>realtime</code> parameter to false.</p>
|
|
2289
|
+
<p><strong>Source filtering</strong></p>
|
|
2290
|
+
<p>By default, the API returns the contents of the <code>_source</code> field unless you have used the <code>stored_fields</code> parameter or the <code>_source</code> field is turned off.
|
|
2291
|
+
You can turn off <code>_source</code> retrieval by using the <code>_source</code> parameter:</p>
|
|
2292
|
+
<pre><code>GET my-index-000001/_doc/0?_source=false
|
|
2293
|
+
</code></pre>
|
|
2294
|
+
<p>If you only need one or two fields from the <code>_source</code>, use the <code>_source_includes</code> or <code>_source_excludes</code> parameters to include or filter out particular fields.
|
|
2295
|
+
This can be helpful with large documents where partial retrieval can save on network overhead
|
|
2296
|
+
Both parameters take a comma separated list of fields or wildcard expressions.
|
|
2297
|
+
For example:</p>
|
|
2298
|
+
<pre><code>GET my-index-000001/_doc/0?_source_includes=*.id&_source_excludes=entities
|
|
2299
|
+
</code></pre>
|
|
2300
|
+
<p>If you only want to specify includes, you can use a shorter notation:</p>
|
|
2301
|
+
<pre><code>GET my-index-000001/_doc/0?_source=*.id
|
|
2302
|
+
</code></pre>
|
|
2303
|
+
<p><strong>Routing</strong></p>
|
|
2304
|
+
<p>If routing is used during indexing, the routing value also needs to be specified to retrieve a document.
|
|
2305
|
+
For example:</p>
|
|
2306
|
+
<pre><code>GET my-index-000001/_doc/2?routing=user1
|
|
2307
|
+
</code></pre>
|
|
2308
|
+
<p>This request gets the document with ID 2, but it is routed based on the user.
|
|
2309
|
+
The document is not fetched if the correct routing is not specified.</p>
|
|
2310
|
+
<p><strong>Distributed</strong></p>
|
|
2311
|
+
<p>The GET operation is hashed into a specific shard ID.
|
|
2312
|
+
It is then redirected to one of the replicas within that shard ID and returns the result.
|
|
2313
|
+
The replicas are the primary shard and its replicas within that shard ID group.
|
|
2314
|
+
This means that the more replicas you have, the better your GET scaling will be.</p>
|
|
2315
|
+
<p><strong>Versioning support</strong></p>
|
|
2316
|
+
<p>You can use the <code>version</code> parameter to retrieve the document only if its current version is equal to the specified one.</p>
|
|
2317
|
+
<p>Internally, Elasticsearch has marked the old document as deleted and added an entirely new document.
|
|
2318
|
+
The old version of the document doesn't disappear immediately, although you won't be able to access it.
|
|
2319
|
+
Elasticsearch cleans up deleted documents in the background as you continue to index more data.</p>
|
|
2320
|
+
|
|
2321
|
+
|
|
2322
|
+
`<https://www.elastic.co/docs/api/doc/elasticsearch/v9/operation/operation-get>`_
|
|
2323
|
+
|
|
2324
|
+
:param index: The name of the index that contains the document.
|
|
2325
|
+
:param id: A unique document identifier.
|
|
2326
|
+
:param force_synthetic_source: Indicates whether the request forces synthetic
|
|
2327
|
+
`_source`. Use this paramater to test if the mapping supports synthetic `_source`
|
|
2328
|
+
and to get a sense of the worst case performance. Fetches with this parameter
|
|
2329
|
+
enabled will be slower than enabling synthetic source natively in the index.
|
|
2330
|
+
:param preference: The node or shard the operation should be performed on. By
|
|
2331
|
+
default, the operation is randomized between the shard replicas. If it is
|
|
2332
|
+
set to `_local`, the operation will prefer to be run on a local allocated
|
|
2333
|
+
shard when possible. If it is set to a custom value, the value is used to
|
|
2334
|
+
guarantee that the same shards will be used for the same custom value. This
|
|
2335
|
+
can help with "jumping values" when hitting different shards in different
|
|
2336
|
+
refresh states. A sample value can be something like the web session ID or
|
|
2337
|
+
the user name.
|
|
2097
2338
|
:param realtime: If `true`, the request is real-time as opposed to near-real-time.
|
|
2098
|
-
:param refresh: If true
|
|
2099
|
-
|
|
2100
|
-
|
|
2101
|
-
|
|
2102
|
-
|
|
2103
|
-
:param
|
|
2104
|
-
the
|
|
2339
|
+
:param refresh: If `true`, the request refreshes the relevant shards before retrieving
|
|
2340
|
+
the document. Setting it to `true` should be done after careful thought and
|
|
2341
|
+
verification that this does not cause a heavy load on the system (and slow
|
|
2342
|
+
down indexing).
|
|
2343
|
+
:param routing: A custom value used to route operations to a specific shard.
|
|
2344
|
+
:param source: Indicates whether to return the `_source` field (`true` or `false`)
|
|
2345
|
+
or lists the fields to return.
|
|
2346
|
+
:param source_excludes: A comma-separated list of source fields to exclude from
|
|
2347
|
+
the response. You can also use this parameter to exclude fields from the
|
|
2348
|
+
subset specified in `_source_includes` query parameter. If the `_source`
|
|
2349
|
+
parameter is `false`, this parameter is ignored.
|
|
2105
2350
|
:param source_includes: A comma-separated list of source fields to include in
|
|
2106
|
-
the response.
|
|
2107
|
-
|
|
2108
|
-
|
|
2109
|
-
|
|
2110
|
-
:param
|
|
2111
|
-
|
|
2112
|
-
|
|
2113
|
-
|
|
2351
|
+
the response. If this parameter is specified, only these source fields are
|
|
2352
|
+
returned. You can exclude fields from this subset using the `_source_excludes`
|
|
2353
|
+
query parameter. If the `_source` parameter is `false`, this parameter is
|
|
2354
|
+
ignored.
|
|
2355
|
+
:param stored_fields: A comma-separated list of stored fields to return as part
|
|
2356
|
+
of a hit. If no fields are specified, no stored fields are included in the
|
|
2357
|
+
response. If this field is specified, the `_source` parameter defaults to
|
|
2358
|
+
`false`. Only leaf fields can be retrieved with the `stored_field` option.
|
|
2359
|
+
Object fields can't be returned;if specified, the request fails.
|
|
2360
|
+
:param version: The version number for concurrency control. It must match the
|
|
2361
|
+
current version of the document for the request to succeed.
|
|
2362
|
+
:param version_type: The version type.
|
|
2114
2363
|
"""
|
|
2115
2364
|
if index in SKIP_IN_PATH:
|
|
2116
2365
|
raise ValueError("Empty value passed for parameter 'index'")
|
|
@@ -2171,12 +2420,19 @@ class AsyncElasticsearch(BaseClient):
|
|
|
2171
2420
|
pretty: t.Optional[bool] = None,
|
|
2172
2421
|
) -> ObjectApiResponse[t.Any]:
|
|
2173
2422
|
"""
|
|
2174
|
-
|
|
2423
|
+
.. raw:: html
|
|
2424
|
+
|
|
2425
|
+
<p>Get a script or search template.
|
|
2426
|
+
Retrieves a stored script or search template.</p>
|
|
2175
2427
|
|
|
2176
|
-
`<https://www.elastic.co/guide/en/elasticsearch/reference/8.17/modules-scripting.html>`_
|
|
2177
2428
|
|
|
2178
|
-
|
|
2179
|
-
|
|
2429
|
+
`<https://www.elastic.co/docs/api/doc/elasticsearch/v9/operation/operation-get-script>`_
|
|
2430
|
+
|
|
2431
|
+
:param id: The identifier for the stored script or search template.
|
|
2432
|
+
:param master_timeout: The period to wait for the master node. If the master
|
|
2433
|
+
node is not available before the timeout expires, the request fails and returns
|
|
2434
|
+
an error. It can also be set to `-1` to indicate that the request should
|
|
2435
|
+
never timeout.
|
|
2180
2436
|
"""
|
|
2181
2437
|
if id in SKIP_IN_PATH:
|
|
2182
2438
|
raise ValueError("Empty value passed for parameter 'id'")
|
|
@@ -2213,9 +2469,13 @@ class AsyncElasticsearch(BaseClient):
|
|
|
2213
2469
|
pretty: t.Optional[bool] = None,
|
|
2214
2470
|
) -> ObjectApiResponse[t.Any]:
|
|
2215
2471
|
"""
|
|
2216
|
-
|
|
2472
|
+
.. raw:: html
|
|
2473
|
+
|
|
2474
|
+
<p>Get script contexts.</p>
|
|
2475
|
+
<p>Get a list of supported script contexts and their methods.</p>
|
|
2476
|
+
|
|
2217
2477
|
|
|
2218
|
-
`<https://www.elastic.co/
|
|
2478
|
+
`<https://www.elastic.co/docs/api/doc/elasticsearch/v9/operation/operation-get-script-context>`_
|
|
2219
2479
|
"""
|
|
2220
2480
|
__path_parts: t.Dict[str, str] = {}
|
|
2221
2481
|
__path = "/_script_context"
|
|
@@ -2248,9 +2508,13 @@ class AsyncElasticsearch(BaseClient):
|
|
|
2248
2508
|
pretty: t.Optional[bool] = None,
|
|
2249
2509
|
) -> ObjectApiResponse[t.Any]:
|
|
2250
2510
|
"""
|
|
2251
|
-
|
|
2511
|
+
.. raw:: html
|
|
2512
|
+
|
|
2513
|
+
<p>Get script languages.</p>
|
|
2514
|
+
<p>Get a list of available script types, languages, and contexts.</p>
|
|
2515
|
+
|
|
2252
2516
|
|
|
2253
|
-
`<https://www.elastic.co/
|
|
2517
|
+
`<https://www.elastic.co/docs/api/doc/elasticsearch/v9/operation/operation-get-script-languages>`_
|
|
2254
2518
|
"""
|
|
2255
2519
|
__path_parts: t.Dict[str, str] = {}
|
|
2256
2520
|
__path = "/_script_language"
|
|
@@ -2303,29 +2567,41 @@ class AsyncElasticsearch(BaseClient):
|
|
|
2303
2567
|
] = None,
|
|
2304
2568
|
) -> ObjectApiResponse[t.Any]:
|
|
2305
2569
|
"""
|
|
2306
|
-
|
|
2570
|
+
.. raw:: html
|
|
2307
2571
|
|
|
2308
|
-
|
|
2572
|
+
<p>Get a document's source.</p>
|
|
2573
|
+
<p>Get the source of a document.
|
|
2574
|
+
For example:</p>
|
|
2575
|
+
<pre><code>GET my-index-000001/_source/1
|
|
2576
|
+
</code></pre>
|
|
2577
|
+
<p>You can use the source filtering parameters to control which parts of the <code>_source</code> are returned:</p>
|
|
2578
|
+
<pre><code>GET my-index-000001/_source/1/?_source_includes=*.id&_source_excludes=entities
|
|
2579
|
+
</code></pre>
|
|
2309
2580
|
|
|
2310
|
-
|
|
2311
|
-
|
|
2312
|
-
|
|
2313
|
-
|
|
2314
|
-
:param
|
|
2315
|
-
:param
|
|
2316
|
-
|
|
2317
|
-
:param
|
|
2318
|
-
:param
|
|
2319
|
-
|
|
2581
|
+
|
|
2582
|
+
`<https://www.elastic.co/docs/api/doc/elasticsearch/v9/operation/operation-get>`_
|
|
2583
|
+
|
|
2584
|
+
:param index: The name of the index that contains the document.
|
|
2585
|
+
:param id: A unique document identifier.
|
|
2586
|
+
:param preference: The node or shard the operation should be performed on. By
|
|
2587
|
+
default, the operation is randomized between the shard replicas.
|
|
2588
|
+
:param realtime: If `true`, the request is real-time as opposed to near-real-time.
|
|
2589
|
+
:param refresh: If `true`, the request refreshes the relevant shards before retrieving
|
|
2590
|
+
the document. Setting it to `true` should be done after careful thought and
|
|
2591
|
+
verification that this does not cause a heavy load on the system (and slow
|
|
2592
|
+
down indexing).
|
|
2593
|
+
:param routing: A custom value used to route operations to a specific shard.
|
|
2594
|
+
:param source: Indicates whether to return the `_source` field (`true` or `false`)
|
|
2595
|
+
or lists the fields to return.
|
|
2320
2596
|
:param source_excludes: A comma-separated list of source fields to exclude in
|
|
2321
2597
|
the response.
|
|
2322
2598
|
:param source_includes: A comma-separated list of source fields to include in
|
|
2323
2599
|
the response.
|
|
2324
|
-
:param stored_fields:
|
|
2325
|
-
|
|
2326
|
-
|
|
2327
|
-
succeed.
|
|
2328
|
-
:param version_type:
|
|
2600
|
+
:param stored_fields: A comma-separated list of stored fields to return as part
|
|
2601
|
+
of a hit.
|
|
2602
|
+
:param version: The version number for concurrency control. It must match the
|
|
2603
|
+
current version of the document for the request to succeed.
|
|
2604
|
+
:param version_type: The version type.
|
|
2329
2605
|
"""
|
|
2330
2606
|
if index in SKIP_IN_PATH:
|
|
2331
2607
|
raise ValueError("Empty value passed for parameter 'index'")
|
|
@@ -2386,28 +2662,24 @@ class AsyncElasticsearch(BaseClient):
|
|
|
2386
2662
|
verbose: t.Optional[bool] = None,
|
|
2387
2663
|
) -> ObjectApiResponse[t.Any]:
|
|
2388
2664
|
"""
|
|
2389
|
-
|
|
2390
|
-
|
|
2391
|
-
|
|
2392
|
-
|
|
2393
|
-
|
|
2394
|
-
|
|
2395
|
-
|
|
2396
|
-
|
|
2397
|
-
|
|
2398
|
-
|
|
2399
|
-
|
|
2400
|
-
|
|
2401
|
-
|
|
2402
|
-
|
|
2403
|
-
|
|
2404
|
-
|
|
2405
|
-
|
|
2406
|
-
|
|
2407
|
-
for health status, set verbose to false to disable the more expensive analysis
|
|
2408
|
-
logic.
|
|
2409
|
-
|
|
2410
|
-
`<https://www.elastic.co/guide/en/elasticsearch/reference/8.17/health-api.html>`_
|
|
2665
|
+
.. raw:: html
|
|
2666
|
+
|
|
2667
|
+
<p>Get the cluster health.
|
|
2668
|
+
Get a report with the health status of an Elasticsearch cluster.
|
|
2669
|
+
The report contains a list of indicators that compose Elasticsearch functionality.</p>
|
|
2670
|
+
<p>Each indicator has a health status of: green, unknown, yellow or red.
|
|
2671
|
+
The indicator will provide an explanation and metadata describing the reason for its current health status.</p>
|
|
2672
|
+
<p>The cluster’s status is controlled by the worst indicator status.</p>
|
|
2673
|
+
<p>In the event that an indicator’s status is non-green, a list of impacts may be present in the indicator result which detail the functionalities that are negatively affected by the health issue.
|
|
2674
|
+
Each impact carries with it a severity level, an area of the system that is affected, and a simple description of the impact on the system.</p>
|
|
2675
|
+
<p>Some health indicators can determine the root cause of a health problem and prescribe a set of steps that can be performed in order to improve the health of the system.
|
|
2676
|
+
The root cause and remediation steps are encapsulated in a diagnosis.
|
|
2677
|
+
A diagnosis contains a cause detailing a root cause analysis, an action containing a brief description of the steps to take to fix the problem, the list of affected resources (if applicable), and a detailed step-by-step troubleshooting guide to fix the diagnosed problem.</p>
|
|
2678
|
+
<p>NOTE: The health indicators perform root cause analysis of non-green health statuses. This can be computationally expensive when called frequently.
|
|
2679
|
+
When setting up automated polling of the API for health status, set verbose to false to disable the more expensive analysis logic.</p>
|
|
2680
|
+
|
|
2681
|
+
|
|
2682
|
+
`<https://www.elastic.co/docs/api/doc/elasticsearch/v9/operation/operation-health-report>`_
|
|
2411
2683
|
|
|
2412
2684
|
:param feature: A feature of the cluster, as returned by the top-level health
|
|
2413
2685
|
report API.
|
|
@@ -2462,6 +2734,7 @@ class AsyncElasticsearch(BaseClient):
|
|
|
2462
2734
|
human: t.Optional[bool] = None,
|
|
2463
2735
|
if_primary_term: t.Optional[int] = None,
|
|
2464
2736
|
if_seq_no: t.Optional[int] = None,
|
|
2737
|
+
include_source_on_error: t.Optional[bool] = None,
|
|
2465
2738
|
op_type: t.Optional[t.Union[str, t.Literal["create", "index"]]] = None,
|
|
2466
2739
|
pipeline: t.Optional[str] = None,
|
|
2467
2740
|
pretty: t.Optional[bool] = None,
|
|
@@ -2480,44 +2753,148 @@ class AsyncElasticsearch(BaseClient):
|
|
|
2480
2753
|
] = None,
|
|
2481
2754
|
) -> ObjectApiResponse[t.Any]:
|
|
2482
2755
|
"""
|
|
2483
|
-
|
|
2484
|
-
|
|
2485
|
-
|
|
2486
|
-
|
|
2487
|
-
|
|
2488
|
-
|
|
2489
|
-
|
|
2756
|
+
.. raw:: html
|
|
2757
|
+
|
|
2758
|
+
<p>Create or update a document in an index.</p>
|
|
2759
|
+
<p>Add a JSON document to the specified data stream or index and make it searchable.
|
|
2760
|
+
If the target is an index and the document already exists, the request updates the document and increments its version.</p>
|
|
2761
|
+
<p>NOTE: You cannot use this API to send update requests for existing documents in a data stream.</p>
|
|
2762
|
+
<p>If the Elasticsearch security features are enabled, you must have the following index privileges for the target data stream, index, or index alias:</p>
|
|
2763
|
+
<ul>
|
|
2764
|
+
<li>To add or overwrite a document using the <code>PUT /<target>/_doc/<_id></code> request format, you must have the <code>create</code>, <code>index</code>, or <code>write</code> index privilege.</li>
|
|
2765
|
+
<li>To add a document using the <code>POST /<target>/_doc/</code> request format, you must have the <code>create_doc</code>, <code>create</code>, <code>index</code>, or <code>write</code> index privilege.</li>
|
|
2766
|
+
<li>To automatically create a data stream or index with this API request, you must have the <code>auto_configure</code>, <code>create_index</code>, or <code>manage</code> index privilege.</li>
|
|
2767
|
+
</ul>
|
|
2768
|
+
<p>Automatic data stream creation requires a matching index template with data stream enabled.</p>
|
|
2769
|
+
<p>NOTE: Replica shards might not all be started when an indexing operation returns successfully.
|
|
2770
|
+
By default, only the primary is required. Set <code>wait_for_active_shards</code> to change this default behavior.</p>
|
|
2771
|
+
<p><strong>Automatically create data streams and indices</strong></p>
|
|
2772
|
+
<p>If the request's target doesn't exist and matches an index template with a <code>data_stream</code> definition, the index operation automatically creates the data stream.</p>
|
|
2773
|
+
<p>If the target doesn't exist and doesn't match a data stream template, the operation automatically creates the index and applies any matching index templates.</p>
|
|
2774
|
+
<p>NOTE: Elasticsearch includes several built-in index templates. To avoid naming collisions with these templates, refer to index pattern documentation.</p>
|
|
2775
|
+
<p>If no mapping exists, the index operation creates a dynamic mapping.
|
|
2776
|
+
By default, new fields and objects are automatically added to the mapping if needed.</p>
|
|
2777
|
+
<p>Automatic index creation is controlled by the <code>action.auto_create_index</code> setting.
|
|
2778
|
+
If it is <code>true</code>, any index can be created automatically.
|
|
2779
|
+
You can modify this setting to explicitly allow or block automatic creation of indices that match specified patterns or set it to <code>false</code> to turn off automatic index creation entirely.
|
|
2780
|
+
Specify a comma-separated list of patterns you want to allow or prefix each pattern with <code>+</code> or <code>-</code> to indicate whether it should be allowed or blocked.
|
|
2781
|
+
When a list is specified, the default behaviour is to disallow.</p>
|
|
2782
|
+
<p>NOTE: The <code>action.auto_create_index</code> setting affects the automatic creation of indices only.
|
|
2783
|
+
It does not affect the creation of data streams.</p>
|
|
2784
|
+
<p><strong>Optimistic concurrency control</strong></p>
|
|
2785
|
+
<p>Index operations can be made conditional and only be performed if the last modification to the document was assigned the sequence number and primary term specified by the <code>if_seq_no</code> and <code>if_primary_term</code> parameters.
|
|
2786
|
+
If a mismatch is detected, the operation will result in a <code>VersionConflictException</code> and a status code of <code>409</code>.</p>
|
|
2787
|
+
<p><strong>Routing</strong></p>
|
|
2788
|
+
<p>By default, shard placement — or routing — is controlled by using a hash of the document's ID value.
|
|
2789
|
+
For more explicit control, the value fed into the hash function used by the router can be directly specified on a per-operation basis using the <code>routing</code> parameter.</p>
|
|
2790
|
+
<p>When setting up explicit mapping, you can also use the <code>_routing</code> field to direct the index operation to extract the routing value from the document itself.
|
|
2791
|
+
This does come at the (very minimal) cost of an additional document parsing pass.
|
|
2792
|
+
If the <code>_routing</code> mapping is defined and set to be required, the index operation will fail if no routing value is provided or extracted.</p>
|
|
2793
|
+
<p>NOTE: Data streams do not support custom routing unless they were created with the <code>allow_custom_routing</code> setting enabled in the template.</p>
|
|
2794
|
+
<p><strong>Distributed</strong></p>
|
|
2795
|
+
<p>The index operation is directed to the primary shard based on its route and performed on the actual node containing this shard.
|
|
2796
|
+
After the primary shard completes the operation, if needed, the update is distributed to applicable replicas.</p>
|
|
2797
|
+
<p><strong>Active shards</strong></p>
|
|
2798
|
+
<p>To improve the resiliency of writes to the system, indexing operations can be configured to wait for a certain number of active shard copies before proceeding with the operation.
|
|
2799
|
+
If the requisite number of active shard copies are not available, then the write operation must wait and retry, until either the requisite shard copies have started or a timeout occurs.
|
|
2800
|
+
By default, write operations only wait for the primary shards to be active before proceeding (that is to say <code>wait_for_active_shards</code> is <code>1</code>).
|
|
2801
|
+
This default can be overridden in the index settings dynamically by setting <code>index.write.wait_for_active_shards</code>.
|
|
2802
|
+
To alter this behavior per operation, use the <code>wait_for_active_shards request</code> parameter.</p>
|
|
2803
|
+
<p>Valid values are all or any positive integer up to the total number of configured copies per shard in the index (which is <code>number_of_replicas</code>+1).
|
|
2804
|
+
Specifying a negative value or a number greater than the number of shard copies will throw an error.</p>
|
|
2805
|
+
<p>For example, suppose you have a cluster of three nodes, A, B, and C and you create an index index with the number of replicas set to 3 (resulting in 4 shard copies, one more copy than there are nodes).
|
|
2806
|
+
If you attempt an indexing operation, by default the operation will only ensure the primary copy of each shard is available before proceeding.
|
|
2807
|
+
This means that even if B and C went down and A hosted the primary shard copies, the indexing operation would still proceed with only one copy of the data.
|
|
2808
|
+
If <code>wait_for_active_shards</code> is set on the request to <code>3</code> (and all three nodes are up), the indexing operation will require 3 active shard copies before proceeding.
|
|
2809
|
+
This requirement should be met because there are 3 active nodes in the cluster, each one holding a copy of the shard.
|
|
2810
|
+
However, if you set <code>wait_for_active_shards</code> to <code>all</code> (or to <code>4</code>, which is the same in this situation), the indexing operation will not proceed as you do not have all 4 copies of each shard active in the index.
|
|
2811
|
+
The operation will timeout unless a new node is brought up in the cluster to host the fourth copy of the shard.</p>
|
|
2812
|
+
<p>It is important to note that this setting greatly reduces the chances of the write operation not writing to the requisite number of shard copies, but it does not completely eliminate the possibility, because this check occurs before the write operation starts.
|
|
2813
|
+
After the write operation is underway, it is still possible for replication to fail on any number of shard copies but still succeed on the primary.
|
|
2814
|
+
The <code>_shards</code> section of the API response reveals the number of shard copies on which replication succeeded and failed.</p>
|
|
2815
|
+
<p><strong>No operation (noop) updates</strong></p>
|
|
2816
|
+
<p>When updating a document by using this API, a new version of the document is always created even if the document hasn't changed.
|
|
2817
|
+
If this isn't acceptable use the <code>_update</code> API with <code>detect_noop</code> set to <code>true</code>.
|
|
2818
|
+
The <code>detect_noop</code> option isn't available on this API because it doesn’t fetch the old source and isn't able to compare it against the new source.</p>
|
|
2819
|
+
<p>There isn't a definitive rule for when noop updates aren't acceptable.
|
|
2820
|
+
It's a combination of lots of factors like how frequently your data source sends updates that are actually noops and how many queries per second Elasticsearch runs on the shard receiving the updates.</p>
|
|
2821
|
+
<p><strong>Versioning</strong></p>
|
|
2822
|
+
<p>Each indexed document is given a version number.
|
|
2823
|
+
By default, internal versioning is used that starts at 1 and increments with each update, deletes included.
|
|
2824
|
+
Optionally, the version number can be set to an external value (for example, if maintained in a database).
|
|
2825
|
+
To enable this functionality, <code>version_type</code> should be set to <code>external</code>.
|
|
2826
|
+
The value provided must be a numeric, long value greater than or equal to 0, and less than around <code>9.2e+18</code>.</p>
|
|
2827
|
+
<p>NOTE: Versioning is completely real time, and is not affected by the near real time aspects of search operations.
|
|
2828
|
+
If no version is provided, the operation runs without any version checks.</p>
|
|
2829
|
+
<p>When using the external version type, the system checks to see if the version number passed to the index request is greater than the version of the currently stored document.
|
|
2830
|
+
If true, the document will be indexed and the new version number used.
|
|
2831
|
+
If the value provided is less than or equal to the stored document's version number, a version conflict will occur and the index operation will fail. For example:</p>
|
|
2832
|
+
<pre><code>PUT my-index-000001/_doc/1?version=2&version_type=external
|
|
2833
|
+
{
|
|
2834
|
+
"user": {
|
|
2835
|
+
"id": "elkbee"
|
|
2836
|
+
}
|
|
2837
|
+
}
|
|
2838
|
+
|
|
2839
|
+
In this example, the operation will succeed since the supplied version of 2 is higher than the current document version of 1.
|
|
2840
|
+
If the document was already updated and its version was set to 2 or higher, the indexing command will fail and result in a conflict (409 HTTP status code).
|
|
2841
|
+
|
|
2842
|
+
A nice side effect is that there is no need to maintain strict ordering of async indexing operations run as a result of changes to a source database, as long as version numbers from the source database are used.
|
|
2843
|
+
Even the simple case of updating the Elasticsearch index using data from a database is simplified if external versioning is used, as only the latest version will be used if the index operations arrive out of order.
|
|
2844
|
+
</code></pre>
|
|
2845
|
+
|
|
2846
|
+
|
|
2847
|
+
`<https://www.elastic.co/docs/api/doc/elasticsearch/v9/operation/operation-create>`_
|
|
2848
|
+
|
|
2849
|
+
:param index: The name of the data stream or index to target. If the target doesn't
|
|
2850
|
+
exist and matches the name or wildcard (`*`) pattern of an index template
|
|
2851
|
+
with a `data_stream` definition, this request creates the data stream. If
|
|
2852
|
+
the target doesn't exist and doesn't match a data stream template, this request
|
|
2853
|
+
creates the index. You can check for existing targets with the resolve index
|
|
2854
|
+
API.
|
|
2490
2855
|
:param document:
|
|
2491
|
-
:param id:
|
|
2856
|
+
:param id: A unique identifier for the document. To automatically generate a
|
|
2857
|
+
document ID, use the `POST /<target>/_doc/` request format and omit this
|
|
2858
|
+
parameter.
|
|
2492
2859
|
:param if_primary_term: Only perform the operation if the document has this primary
|
|
2493
2860
|
term.
|
|
2494
2861
|
:param if_seq_no: Only perform the operation if the document has this sequence
|
|
2495
2862
|
number.
|
|
2496
|
-
:param
|
|
2863
|
+
:param include_source_on_error: True or false if to include the document source
|
|
2864
|
+
in the error message in case of parsing errors.
|
|
2865
|
+
:param op_type: Set to `create` to only index the document if it does not already
|
|
2497
2866
|
exist (put if absent). If a document with the specified `_id` already exists,
|
|
2498
|
-
the indexing operation will fail.
|
|
2499
|
-
|
|
2500
|
-
|
|
2501
|
-
|
|
2867
|
+
the indexing operation will fail. The behavior is the same as using the `<index>/_create`
|
|
2868
|
+
endpoint. If a document ID is specified, this paramater defaults to `index`.
|
|
2869
|
+
Otherwise, it defaults to `create`. If the request targets a data stream,
|
|
2870
|
+
an `op_type` of `create` is required.
|
|
2871
|
+
:param pipeline: The ID of the pipeline to use to preprocess incoming documents.
|
|
2502
2872
|
If the index has a default ingest pipeline specified, then setting the value
|
|
2503
2873
|
to `_none` disables the default ingest pipeline for this request. If a final
|
|
2504
2874
|
pipeline is configured it will always run, regardless of the value of this
|
|
2505
2875
|
parameter.
|
|
2506
2876
|
:param refresh: If `true`, Elasticsearch refreshes the affected shards to make
|
|
2507
|
-
this operation visible to search
|
|
2508
|
-
make this operation visible to search
|
|
2509
|
-
Valid values: `true`, `false`, `wait_for`.
|
|
2877
|
+
this operation visible to search. If `wait_for`, it waits for a refresh to
|
|
2878
|
+
make this operation visible to search. If `false`, it does nothing with refreshes.
|
|
2510
2879
|
:param require_alias: If `true`, the destination must be an index alias.
|
|
2511
|
-
:param routing:
|
|
2512
|
-
|
|
2513
|
-
|
|
2514
|
-
|
|
2515
|
-
|
|
2516
|
-
|
|
2517
|
-
|
|
2880
|
+
:param routing: A custom value that is used to route operations to a specific
|
|
2881
|
+
shard.
|
|
2882
|
+
:param timeout: The period the request waits for the following operations: automatic
|
|
2883
|
+
index creation, dynamic mapping updates, waiting for active shards. This
|
|
2884
|
+
parameter is useful for situations where the primary shard assigned to perform
|
|
2885
|
+
the operation might not be available when the operation runs. Some reasons
|
|
2886
|
+
for this might be that the primary shard is currently recovering from a gateway
|
|
2887
|
+
or undergoing relocation. By default, the operation will wait on the primary
|
|
2888
|
+
shard to become available for at least 1 minute before failing and responding
|
|
2889
|
+
with an error. The actual wait time could be longer, particularly when multiple
|
|
2890
|
+
waits occur.
|
|
2891
|
+
:param version: An explicit version number for concurrency control. It must be
|
|
2892
|
+
a non-negative long number.
|
|
2893
|
+
:param version_type: The version type.
|
|
2518
2894
|
:param wait_for_active_shards: The number of shard copies that must be active
|
|
2519
|
-
before proceeding with the operation.
|
|
2520
|
-
up to the total number of shards in the index (`number_of_replicas+1`).
|
|
2895
|
+
before proceeding with the operation. You can set it to `all` or any positive
|
|
2896
|
+
integer up to the total number of shards in the index (`number_of_replicas+1`).
|
|
2897
|
+
The default value of `1` means it waits for each primary shard to be active.
|
|
2521
2898
|
"""
|
|
2522
2899
|
if index in SKIP_IN_PATH:
|
|
2523
2900
|
raise ValueError("Empty value passed for parameter 'index'")
|
|
@@ -2549,6 +2926,8 @@ class AsyncElasticsearch(BaseClient):
|
|
|
2549
2926
|
__query["if_primary_term"] = if_primary_term
|
|
2550
2927
|
if if_seq_no is not None:
|
|
2551
2928
|
__query["if_seq_no"] = if_seq_no
|
|
2929
|
+
if include_source_on_error is not None:
|
|
2930
|
+
__query["include_source_on_error"] = include_source_on_error
|
|
2552
2931
|
if op_type is not None:
|
|
2553
2932
|
__query["op_type"] = op_type
|
|
2554
2933
|
if pipeline is not None:
|
|
@@ -2591,104 +2970,17 @@ class AsyncElasticsearch(BaseClient):
|
|
|
2591
2970
|
pretty: t.Optional[bool] = None,
|
|
2592
2971
|
) -> ObjectApiResponse[t.Any]:
|
|
2593
2972
|
"""
|
|
2594
|
-
|
|
2595
|
-
|
|
2596
|
-
|
|
2597
|
-
|
|
2598
|
-
|
|
2599
|
-
|
|
2600
|
-
|
|
2601
|
-
if error_trace is not None:
|
|
2602
|
-
__query["error_trace"] = error_trace
|
|
2603
|
-
if filter_path is not None:
|
|
2604
|
-
__query["filter_path"] = filter_path
|
|
2605
|
-
if human is not None:
|
|
2606
|
-
__query["human"] = human
|
|
2607
|
-
if pretty is not None:
|
|
2608
|
-
__query["pretty"] = pretty
|
|
2609
|
-
__headers = {"accept": "application/json"}
|
|
2610
|
-
return await self.perform_request( # type: ignore[return-value]
|
|
2611
|
-
"GET",
|
|
2612
|
-
__path,
|
|
2613
|
-
params=__query,
|
|
2614
|
-
headers=__headers,
|
|
2615
|
-
endpoint_id="info",
|
|
2616
|
-
path_parts=__path_parts,
|
|
2617
|
-
)
|
|
2618
|
-
|
|
2619
|
-
@_rewrite_parameters(
|
|
2620
|
-
body_fields=(
|
|
2621
|
-
"knn",
|
|
2622
|
-
"docvalue_fields",
|
|
2623
|
-
"fields",
|
|
2624
|
-
"filter",
|
|
2625
|
-
"source",
|
|
2626
|
-
"stored_fields",
|
|
2627
|
-
),
|
|
2628
|
-
parameter_aliases={"_source": "source"},
|
|
2629
|
-
)
|
|
2630
|
-
@_stability_warning(Stability.EXPERIMENTAL)
|
|
2631
|
-
async def knn_search(
|
|
2632
|
-
self,
|
|
2633
|
-
*,
|
|
2634
|
-
index: t.Union[str, t.Sequence[str]],
|
|
2635
|
-
knn: t.Optional[t.Mapping[str, t.Any]] = None,
|
|
2636
|
-
docvalue_fields: t.Optional[t.Sequence[t.Mapping[str, t.Any]]] = None,
|
|
2637
|
-
error_trace: t.Optional[bool] = None,
|
|
2638
|
-
fields: t.Optional[t.Union[str, t.Sequence[str]]] = None,
|
|
2639
|
-
filter: t.Optional[
|
|
2640
|
-
t.Union[t.Mapping[str, t.Any], t.Sequence[t.Mapping[str, t.Any]]]
|
|
2641
|
-
] = None,
|
|
2642
|
-
filter_path: t.Optional[t.Union[str, t.Sequence[str]]] = None,
|
|
2643
|
-
human: t.Optional[bool] = None,
|
|
2644
|
-
pretty: t.Optional[bool] = None,
|
|
2645
|
-
routing: t.Optional[str] = None,
|
|
2646
|
-
source: t.Optional[t.Union[bool, t.Mapping[str, t.Any]]] = None,
|
|
2647
|
-
stored_fields: t.Optional[t.Union[str, t.Sequence[str]]] = None,
|
|
2648
|
-
body: t.Optional[t.Dict[str, t.Any]] = None,
|
|
2649
|
-
) -> ObjectApiResponse[t.Any]:
|
|
2650
|
-
"""
|
|
2651
|
-
Run a knn search. NOTE: The kNN search API has been replaced by the `knn` option
|
|
2652
|
-
in the search API. Perform a k-nearest neighbor (kNN) search on a dense_vector
|
|
2653
|
-
field and return the matching documents. Given a query vector, the API finds
|
|
2654
|
-
the k closest vectors and returns those documents as search hits. Elasticsearch
|
|
2655
|
-
uses the HNSW algorithm to support efficient kNN search. Like most kNN algorithms,
|
|
2656
|
-
HNSW is an approximate method that sacrifices result accuracy for improved search
|
|
2657
|
-
speed. This means the results returned are not always the true k closest neighbors.
|
|
2658
|
-
The kNN search API supports restricting the search using a filter. The search
|
|
2659
|
-
will return the top k documents that also match the filter query.
|
|
2660
|
-
|
|
2661
|
-
`<https://www.elastic.co/guide/en/elasticsearch/reference/8.17/search-search.html>`_
|
|
2662
|
-
|
|
2663
|
-
:param index: A comma-separated list of index names to search; use `_all` or
|
|
2664
|
-
to perform the operation on all indices
|
|
2665
|
-
:param knn: kNN query to execute
|
|
2666
|
-
:param docvalue_fields: The request returns doc values for field names matching
|
|
2667
|
-
these patterns in the hits.fields property of the response. Accepts wildcard
|
|
2668
|
-
(*) patterns.
|
|
2669
|
-
:param fields: The request returns values for field names matching these patterns
|
|
2670
|
-
in the hits.fields property of the response. Accepts wildcard (*) patterns.
|
|
2671
|
-
:param filter: Query to filter the documents that can match. The kNN search will
|
|
2672
|
-
return the top `k` documents that also match this filter. The value can be
|
|
2673
|
-
a single query or a list of queries. If `filter` isn't provided, all documents
|
|
2674
|
-
are allowed to match.
|
|
2675
|
-
:param routing: A comma-separated list of specific routing values
|
|
2676
|
-
:param source: Indicates which source fields are returned for matching documents.
|
|
2677
|
-
These fields are returned in the hits._source property of the search response.
|
|
2678
|
-
:param stored_fields: List of stored fields to return as part of a hit. If no
|
|
2679
|
-
fields are specified, no stored fields are included in the response. If this
|
|
2680
|
-
field is specified, the _source parameter defaults to false. You can pass
|
|
2681
|
-
_source: true to return both source fields and stored fields in the search
|
|
2682
|
-
response.
|
|
2973
|
+
.. raw:: html
|
|
2974
|
+
|
|
2975
|
+
<p>Get cluster info.
|
|
2976
|
+
Get basic build, version, and cluster information.</p>
|
|
2977
|
+
|
|
2978
|
+
|
|
2979
|
+
`<https://www.elastic.co/docs/api/doc/elasticsearch/v9/group/endpoint-info>`_
|
|
2683
2980
|
"""
|
|
2684
|
-
|
|
2685
|
-
|
|
2686
|
-
if knn is None and body is None:
|
|
2687
|
-
raise ValueError("Empty value passed for parameter 'knn'")
|
|
2688
|
-
__path_parts: t.Dict[str, str] = {"index": _quote(index)}
|
|
2689
|
-
__path = f'/{__path_parts["index"]}/_knn_search'
|
|
2981
|
+
__path_parts: t.Dict[str, str] = {}
|
|
2982
|
+
__path = "/"
|
|
2690
2983
|
__query: t.Dict[str, t.Any] = {}
|
|
2691
|
-
__body: t.Dict[str, t.Any] = body if body is not None else {}
|
|
2692
2984
|
if error_trace is not None:
|
|
2693
2985
|
__query["error_trace"] = error_trace
|
|
2694
2986
|
if filter_path is not None:
|
|
@@ -2697,33 +2989,13 @@ class AsyncElasticsearch(BaseClient):
|
|
|
2697
2989
|
__query["human"] = human
|
|
2698
2990
|
if pretty is not None:
|
|
2699
2991
|
__query["pretty"] = pretty
|
|
2700
|
-
if routing is not None:
|
|
2701
|
-
__query["routing"] = routing
|
|
2702
|
-
if not __body:
|
|
2703
|
-
if knn is not None:
|
|
2704
|
-
__body["knn"] = knn
|
|
2705
|
-
if docvalue_fields is not None:
|
|
2706
|
-
__body["docvalue_fields"] = docvalue_fields
|
|
2707
|
-
if fields is not None:
|
|
2708
|
-
__body["fields"] = fields
|
|
2709
|
-
if filter is not None:
|
|
2710
|
-
__body["filter"] = filter
|
|
2711
|
-
if source is not None:
|
|
2712
|
-
__body["_source"] = source
|
|
2713
|
-
if stored_fields is not None:
|
|
2714
|
-
__body["stored_fields"] = stored_fields
|
|
2715
|
-
if not __body:
|
|
2716
|
-
__body = None # type: ignore[assignment]
|
|
2717
2992
|
__headers = {"accept": "application/json"}
|
|
2718
|
-
if __body is not None:
|
|
2719
|
-
__headers["content-type"] = "application/json"
|
|
2720
2993
|
return await self.perform_request( # type: ignore[return-value]
|
|
2721
|
-
"
|
|
2994
|
+
"GET",
|
|
2722
2995
|
__path,
|
|
2723
2996
|
params=__query,
|
|
2724
2997
|
headers=__headers,
|
|
2725
|
-
|
|
2726
|
-
endpoint_id="knn_search",
|
|
2998
|
+
endpoint_id="info",
|
|
2727
2999
|
path_parts=__path_parts,
|
|
2728
3000
|
)
|
|
2729
3001
|
|
|
@@ -2757,12 +3029,23 @@ class AsyncElasticsearch(BaseClient):
|
|
|
2757
3029
|
body: t.Optional[t.Dict[str, t.Any]] = None,
|
|
2758
3030
|
) -> ObjectApiResponse[t.Any]:
|
|
2759
3031
|
"""
|
|
2760
|
-
|
|
2761
|
-
|
|
2762
|
-
|
|
2763
|
-
|
|
3032
|
+
.. raw:: html
|
|
3033
|
+
|
|
3034
|
+
<p>Get multiple documents.</p>
|
|
3035
|
+
<p>Get multiple JSON documents by ID from one or more indices.
|
|
3036
|
+
If you specify an index in the request URI, you only need to specify the document IDs in the request body.
|
|
3037
|
+
To ensure fast responses, this multi get (mget) API responds with partial results if one or more shards fail.</p>
|
|
3038
|
+
<p><strong>Filter source fields</strong></p>
|
|
3039
|
+
<p>By default, the <code>_source</code> field is returned for every document (if stored).
|
|
3040
|
+
Use the <code>_source</code> and <code>_source_include</code> or <code>source_exclude</code> attributes to filter what fields are returned for a particular document.
|
|
3041
|
+
You can include the <code>_source</code>, <code>_source_includes</code>, and <code>_source_excludes</code> query parameters in the request URI to specify the defaults to use when there are no per-document instructions.</p>
|
|
3042
|
+
<p><strong>Get stored fields</strong></p>
|
|
3043
|
+
<p>Use the <code>stored_fields</code> attribute to specify the set of stored fields you want to retrieve.
|
|
3044
|
+
Any requested fields that are not stored are ignored.
|
|
3045
|
+
You can include the <code>stored_fields</code> query parameter in the request URI to specify the defaults to use when there are no per-document instructions.</p>
|
|
2764
3046
|
|
|
2765
|
-
|
|
3047
|
+
|
|
3048
|
+
`<https://www.elastic.co/docs/api/doc/elasticsearch/v9/operation/operation-mget>`_
|
|
2766
3049
|
|
|
2767
3050
|
:param index: Name of the index to retrieve documents from when `ids` are specified,
|
|
2768
3051
|
or when a document in the `docs` array does not specify an index.
|
|
@@ -2881,15 +3164,23 @@ class AsyncElasticsearch(BaseClient):
|
|
|
2881
3164
|
typed_keys: t.Optional[bool] = None,
|
|
2882
3165
|
) -> ObjectApiResponse[t.Any]:
|
|
2883
3166
|
"""
|
|
2884
|
-
|
|
2885
|
-
|
|
2886
|
-
|
|
2887
|
-
|
|
2888
|
-
|
|
2889
|
-
|
|
2890
|
-
|
|
3167
|
+
.. raw:: html
|
|
3168
|
+
|
|
3169
|
+
<p>Run multiple searches.</p>
|
|
3170
|
+
<p>The format of the request is similar to the bulk API format and makes use of the newline delimited JSON (NDJSON) format.
|
|
3171
|
+
The structure is as follows:</p>
|
|
3172
|
+
<pre><code>header\\n
|
|
3173
|
+
body\\n
|
|
3174
|
+
header\\n
|
|
3175
|
+
body\\n
|
|
3176
|
+
</code></pre>
|
|
3177
|
+
<p>This structure is specifically optimized to reduce parsing if a specific search ends up redirected to another node.</p>
|
|
3178
|
+
<p>IMPORTANT: The final line of data must end with a newline character <code>\\n</code>.
|
|
3179
|
+
Each newline character may be preceded by a carriage return <code>\\r</code>.
|
|
3180
|
+
When sending requests to this endpoint the <code>Content-Type</code> header should be set to <code>application/x-ndjson</code>.</p>
|
|
2891
3181
|
|
|
2892
|
-
|
|
3182
|
+
|
|
3183
|
+
`<https://www.elastic.co/docs/api/doc/elasticsearch/v9/operation/operation-msearch>`_
|
|
2893
3184
|
|
|
2894
3185
|
:param searches:
|
|
2895
3186
|
:param index: Comma-separated list of data streams, indices, and index aliases
|
|
@@ -2916,7 +3207,8 @@ class AsyncElasticsearch(BaseClient):
|
|
|
2916
3207
|
computationally expensive named queries on a large number of hits may add
|
|
2917
3208
|
significant overhead.
|
|
2918
3209
|
:param max_concurrent_searches: Maximum number of concurrent searches the multi
|
|
2919
|
-
search API can execute.
|
|
3210
|
+
search API can execute. Defaults to `max(1, (# of data nodes * min(search
|
|
3211
|
+
thread pool size, 10)))`.
|
|
2920
3212
|
:param max_concurrent_shard_requests: Maximum number of concurrent shard requests
|
|
2921
3213
|
that each sub-search request executes per node.
|
|
2922
3214
|
:param pre_filter_shard_size: Defines a threshold that enforces a pre-filter
|
|
@@ -3019,22 +3311,35 @@ class AsyncElasticsearch(BaseClient):
|
|
|
3019
3311
|
typed_keys: t.Optional[bool] = None,
|
|
3020
3312
|
) -> ObjectApiResponse[t.Any]:
|
|
3021
3313
|
"""
|
|
3022
|
-
|
|
3314
|
+
.. raw:: html
|
|
3315
|
+
|
|
3316
|
+
<p>Run multiple templated searches.</p>
|
|
3317
|
+
<p>Run multiple templated searches with a single request.
|
|
3318
|
+
If you are providing a text file or text input to <code>curl</code>, use the <code>--data-binary</code> flag instead of <code>-d</code> to preserve newlines.
|
|
3319
|
+
For example:</p>
|
|
3320
|
+
<pre><code>$ cat requests
|
|
3321
|
+
{ "index": "my-index" }
|
|
3322
|
+
{ "id": "my-search-template", "params": { "query_string": "hello world", "from": 0, "size": 10 }}
|
|
3323
|
+
{ "index": "my-other-index" }
|
|
3324
|
+
{ "id": "my-other-search-template", "params": { "query_type": "match_all" }}
|
|
3325
|
+
|
|
3326
|
+
$ curl -H "Content-Type: application/x-ndjson" -XGET localhost:9200/_msearch/template --data-binary "@requests"; echo
|
|
3327
|
+
</code></pre>
|
|
3328
|
+
|
|
3023
3329
|
|
|
3024
|
-
`<https://www.elastic.co/
|
|
3330
|
+
`<https://www.elastic.co/docs/api/doc/elasticsearch/v9/operation/operation-msearch-template>`_
|
|
3025
3331
|
|
|
3026
3332
|
:param search_templates:
|
|
3027
|
-
:param index:
|
|
3028
|
-
|
|
3029
|
-
parameter or use `*`.
|
|
3333
|
+
:param index: A comma-separated list of data streams, indices, and aliases to
|
|
3334
|
+
search. It supports wildcards (`*`). To search all data streams and indices,
|
|
3335
|
+
omit this parameter or use `*`.
|
|
3030
3336
|
:param ccs_minimize_roundtrips: If `true`, network round-trips are minimized
|
|
3031
3337
|
for cross-cluster search requests.
|
|
3032
|
-
:param max_concurrent_searches:
|
|
3033
|
-
can run.
|
|
3338
|
+
:param max_concurrent_searches: The maximum number of concurrent searches the
|
|
3339
|
+
API can run.
|
|
3034
3340
|
:param rest_total_hits_as_int: If `true`, the response returns `hits.total` as
|
|
3035
3341
|
an integer. If `false`, it returns `hits.total` as an object.
|
|
3036
|
-
:param search_type: The type of the search operation.
|
|
3037
|
-
`dfs_query_then_fetch`.
|
|
3342
|
+
:param search_type: The type of the search operation.
|
|
3038
3343
|
:param typed_keys: If `true`, the response prefixes aggregation and suggester
|
|
3039
3344
|
names with their respective types.
|
|
3040
3345
|
"""
|
|
@@ -3114,34 +3419,41 @@ class AsyncElasticsearch(BaseClient):
|
|
|
3114
3419
|
body: t.Optional[t.Dict[str, t.Any]] = None,
|
|
3115
3420
|
) -> ObjectApiResponse[t.Any]:
|
|
3116
3421
|
"""
|
|
3117
|
-
|
|
3118
|
-
|
|
3119
|
-
|
|
3120
|
-
|
|
3121
|
-
|
|
3422
|
+
.. raw:: html
|
|
3423
|
+
|
|
3424
|
+
<p>Get multiple term vectors.</p>
|
|
3425
|
+
<p>Get multiple term vectors with a single request.
|
|
3426
|
+
You can specify existing documents by index and ID or provide artificial documents in the body of the request.
|
|
3427
|
+
You can specify the index in the request body or request URI.
|
|
3428
|
+
The response contains a <code>docs</code> array with all the fetched termvectors.
|
|
3429
|
+
Each element has the structure provided by the termvectors API.</p>
|
|
3430
|
+
<p><strong>Artificial documents</strong></p>
|
|
3431
|
+
<p>You can also use <code>mtermvectors</code> to generate term vectors for artificial documents provided in the body of the request.
|
|
3432
|
+
The mapping used is determined by the specified <code>_index</code>.</p>
|
|
3122
3433
|
|
|
3123
|
-
`<https://www.elastic.co/guide/en/elasticsearch/reference/8.17/docs-multi-termvectors.html>`_
|
|
3124
3434
|
|
|
3125
|
-
|
|
3126
|
-
|
|
3435
|
+
`<https://www.elastic.co/docs/api/doc/elasticsearch/v9/operation/operation-mtermvectors>`_
|
|
3436
|
+
|
|
3437
|
+
:param index: The name of the index that contains the documents.
|
|
3438
|
+
:param docs: An array of existing or artificial documents.
|
|
3127
3439
|
:param field_statistics: If `true`, the response includes the document count,
|
|
3128
3440
|
sum of document frequencies, and sum of total term frequencies.
|
|
3129
|
-
:param fields:
|
|
3130
|
-
in the statistics.
|
|
3131
|
-
is provided in the `completion_fields` or `fielddata_fields` parameters.
|
|
3132
|
-
:param ids:
|
|
3441
|
+
:param fields: A comma-separated list or wildcard expressions of fields to include
|
|
3442
|
+
in the statistics. It is used as the default list unless a specific field
|
|
3443
|
+
list is provided in the `completion_fields` or `fielddata_fields` parameters.
|
|
3444
|
+
:param ids: A simplified syntax to specify documents by their ID if they're in
|
|
3133
3445
|
the same index.
|
|
3134
3446
|
:param offsets: If `true`, the response includes term offsets.
|
|
3135
3447
|
:param payloads: If `true`, the response includes term payloads.
|
|
3136
3448
|
:param positions: If `true`, the response includes term positions.
|
|
3137
|
-
:param preference:
|
|
3138
|
-
|
|
3449
|
+
:param preference: The node or shard the operation should be performed on. It
|
|
3450
|
+
is random by default.
|
|
3139
3451
|
:param realtime: If true, the request is real-time as opposed to near-real-time.
|
|
3140
|
-
:param routing:
|
|
3452
|
+
:param routing: A custom value used to route operations to a specific shard.
|
|
3141
3453
|
:param term_statistics: If true, the response includes term frequency and document
|
|
3142
3454
|
frequency.
|
|
3143
3455
|
:param version: If `true`, returns the document version as part of a hit.
|
|
3144
|
-
:param version_type:
|
|
3456
|
+
:param version_type: The version type.
|
|
3145
3457
|
"""
|
|
3146
3458
|
__path_parts: t.Dict[str, str]
|
|
3147
3459
|
if index not in SKIP_IN_PATH:
|
|
@@ -3224,42 +3536,68 @@ class AsyncElasticsearch(BaseClient):
|
|
|
3224
3536
|
human: t.Optional[bool] = None,
|
|
3225
3537
|
ignore_unavailable: t.Optional[bool] = None,
|
|
3226
3538
|
index_filter: t.Optional[t.Mapping[str, t.Any]] = None,
|
|
3539
|
+
max_concurrent_shard_requests: t.Optional[int] = None,
|
|
3227
3540
|
preference: t.Optional[str] = None,
|
|
3228
3541
|
pretty: t.Optional[bool] = None,
|
|
3229
3542
|
routing: t.Optional[str] = None,
|
|
3230
3543
|
body: t.Optional[t.Dict[str, t.Any]] = None,
|
|
3231
3544
|
) -> ObjectApiResponse[t.Any]:
|
|
3232
3545
|
"""
|
|
3233
|
-
|
|
3234
|
-
|
|
3235
|
-
|
|
3236
|
-
|
|
3237
|
-
|
|
3238
|
-
|
|
3239
|
-
|
|
3240
|
-
|
|
3241
|
-
|
|
3242
|
-
|
|
3243
|
-
|
|
3546
|
+
.. raw:: html
|
|
3547
|
+
|
|
3548
|
+
<p>Open a point in time.</p>
|
|
3549
|
+
<p>A search request by default runs against the most recent visible data of the target indices,
|
|
3550
|
+
which is called point in time. Elasticsearch pit (point in time) is a lightweight view into the
|
|
3551
|
+
state of the data as it existed when initiated. In some cases, it’s preferred to perform multiple
|
|
3552
|
+
search requests using the same point in time. For example, if refreshes happen between
|
|
3553
|
+
<code>search_after</code> requests, then the results of those requests might not be consistent as changes happening
|
|
3554
|
+
between searches are only visible to the more recent point in time.</p>
|
|
3555
|
+
<p>A point in time must be opened explicitly before being used in search requests.</p>
|
|
3556
|
+
<p>A subsequent search request with the <code>pit</code> parameter must not specify <code>index</code>, <code>routing</code>, or <code>preference</code> values as these parameters are copied from the point in time.</p>
|
|
3557
|
+
<p>Just like regular searches, you can use <code>from</code> and <code>size</code> to page through point in time search results, up to the first 10,000 hits.
|
|
3558
|
+
If you want to retrieve more hits, use PIT with <code>search_after</code>.</p>
|
|
3559
|
+
<p>IMPORTANT: The open point in time request and each subsequent search request can return different identifiers; always use the most recently received ID for the next search request.</p>
|
|
3560
|
+
<p>When a PIT that contains shard failures is used in a search request, the missing are always reported in the search response as a <code>NoShardAvailableActionException</code> exception.
|
|
3561
|
+
To get rid of these exceptions, a new PIT needs to be created so that shards missing from the previous PIT can be handled, assuming they become available in the meantime.</p>
|
|
3562
|
+
<p><strong>Keeping point in time alive</strong></p>
|
|
3563
|
+
<p>The <code>keep_alive</code> parameter, which is passed to a open point in time request and search request, extends the time to live of the corresponding point in time.
|
|
3564
|
+
The value does not need to be long enough to process all data — it just needs to be long enough for the next request.</p>
|
|
3565
|
+
<p>Normally, the background merge process optimizes the index by merging together smaller segments to create new, bigger segments.
|
|
3566
|
+
Once the smaller segments are no longer needed they are deleted.
|
|
3567
|
+
However, open point-in-times prevent the old segments from being deleted since they are still in use.</p>
|
|
3568
|
+
<p>TIP: Keeping older segments alive means that more disk space and file handles are needed.
|
|
3569
|
+
Ensure that you have configured your nodes to have ample free file handles.</p>
|
|
3570
|
+
<p>Additionally, if a segment contains deleted or updated documents then the point in time must keep track of whether each document in the segment was live at the time of the initial search request.
|
|
3571
|
+
Ensure that your nodes have sufficient heap space if you have many open point-in-times on an index that is subject to ongoing deletes or updates.
|
|
3572
|
+
Note that a point-in-time doesn't prevent its associated indices from being deleted.
|
|
3573
|
+
You can check how many point-in-times (that is, search contexts) are open with the nodes stats API.</p>
|
|
3574
|
+
|
|
3575
|
+
|
|
3576
|
+
`<https://www.elastic.co/docs/api/doc/elasticsearch/v9/operation/operation-open-point-in-time>`_
|
|
3244
3577
|
|
|
3245
3578
|
:param index: A comma-separated list of index names to open point in time; use
|
|
3246
3579
|
`_all` or empty string to perform the operation on all indices
|
|
3247
|
-
:param keep_alive:
|
|
3248
|
-
:param allow_partial_search_results:
|
|
3249
|
-
|
|
3250
|
-
|
|
3251
|
-
|
|
3252
|
-
|
|
3253
|
-
|
|
3254
|
-
|
|
3255
|
-
|
|
3580
|
+
:param keep_alive: Extend the length of time that the point in time persists.
|
|
3581
|
+
:param allow_partial_search_results: Indicates whether the point in time tolerates
|
|
3582
|
+
unavailable shards or shard failures when initially creating the PIT. If
|
|
3583
|
+
`false`, creating a point in time request when a shard is missing or unavailable
|
|
3584
|
+
will throw an exception. If `true`, the point in time will contain all the
|
|
3585
|
+
shards that are available at the time of the request.
|
|
3586
|
+
:param expand_wildcards: The type of index that wildcard patterns can match.
|
|
3587
|
+
If the request can target data streams, this argument determines whether
|
|
3588
|
+
wildcard expressions match hidden data streams. It supports comma-separated
|
|
3589
|
+
values, such as `open,hidden`. Valid values are: `all`, `open`, `closed`,
|
|
3590
|
+
`hidden`, `none`.
|
|
3256
3591
|
:param ignore_unavailable: If `false`, the request returns an error if it targets
|
|
3257
3592
|
a missing or closed index.
|
|
3258
|
-
:param index_filter:
|
|
3259
|
-
|
|
3260
|
-
:param
|
|
3261
|
-
|
|
3262
|
-
:param
|
|
3593
|
+
:param index_filter: Filter indices if the provided query rewrites to `match_none`
|
|
3594
|
+
on every shard.
|
|
3595
|
+
:param max_concurrent_shard_requests: Maximum number of concurrent shard requests
|
|
3596
|
+
that each sub-search request executes per node.
|
|
3597
|
+
:param preference: The node or shard the operation should be performed on. By
|
|
3598
|
+
default, it is random.
|
|
3599
|
+
:param routing: A custom value that is used to route operations to a specific
|
|
3600
|
+
shard.
|
|
3263
3601
|
"""
|
|
3264
3602
|
if index in SKIP_IN_PATH:
|
|
3265
3603
|
raise ValueError("Empty value passed for parameter 'index'")
|
|
@@ -3283,6 +3621,8 @@ class AsyncElasticsearch(BaseClient):
|
|
|
3283
3621
|
__query["human"] = human
|
|
3284
3622
|
if ignore_unavailable is not None:
|
|
3285
3623
|
__query["ignore_unavailable"] = ignore_unavailable
|
|
3624
|
+
if max_concurrent_shard_requests is not None:
|
|
3625
|
+
__query["max_concurrent_shard_requests"] = max_concurrent_shard_requests
|
|
3286
3626
|
if preference is not None:
|
|
3287
3627
|
__query["preference"] = preference
|
|
3288
3628
|
if pretty is not None:
|
|
@@ -3325,23 +3665,27 @@ class AsyncElasticsearch(BaseClient):
|
|
|
3325
3665
|
body: t.Optional[t.Dict[str, t.Any]] = None,
|
|
3326
3666
|
) -> ObjectApiResponse[t.Any]:
|
|
3327
3667
|
"""
|
|
3328
|
-
|
|
3329
|
-
|
|
3330
|
-
|
|
3331
|
-
|
|
3332
|
-
|
|
3333
|
-
|
|
3334
|
-
|
|
3335
|
-
|
|
3336
|
-
|
|
3337
|
-
|
|
3338
|
-
|
|
3339
|
-
|
|
3340
|
-
|
|
3341
|
-
|
|
3342
|
-
|
|
3343
|
-
|
|
3344
|
-
|
|
3668
|
+
.. raw:: html
|
|
3669
|
+
|
|
3670
|
+
<p>Create or update a script or search template.
|
|
3671
|
+
Creates or updates a stored script or search template.</p>
|
|
3672
|
+
|
|
3673
|
+
|
|
3674
|
+
`<https://www.elastic.co/docs/api/doc/elasticsearch/v9/operation/operation-put-script>`_
|
|
3675
|
+
|
|
3676
|
+
:param id: The identifier for the stored script or search template. It must be
|
|
3677
|
+
unique within the cluster.
|
|
3678
|
+
:param script: The script or search template, its parameters, and its language.
|
|
3679
|
+
:param context: The context in which the script or search template should run.
|
|
3680
|
+
To prevent errors, the API immediately compiles the script or template in
|
|
3681
|
+
this context.
|
|
3682
|
+
:param master_timeout: The period to wait for a connection to the master node.
|
|
3683
|
+
If no response is received before the timeout expires, the request fails
|
|
3684
|
+
and returns an error. It can also be set to `-1` to indicate that the request
|
|
3685
|
+
should never timeout.
|
|
3686
|
+
:param timeout: The period to wait for a response. If no response is received
|
|
3687
|
+
before the timeout expires, the request fails and returns an error. It can
|
|
3688
|
+
also be set to `-1` to indicate that the request should never timeout.
|
|
3345
3689
|
"""
|
|
3346
3690
|
if id in SKIP_IN_PATH:
|
|
3347
3691
|
raise ValueError("Empty value passed for parameter 'id'")
|
|
@@ -3411,14 +3755,17 @@ class AsyncElasticsearch(BaseClient):
|
|
|
3411
3755
|
body: t.Optional[t.Dict[str, t.Any]] = None,
|
|
3412
3756
|
) -> ObjectApiResponse[t.Any]:
|
|
3413
3757
|
"""
|
|
3414
|
-
|
|
3415
|
-
|
|
3758
|
+
.. raw:: html
|
|
3759
|
+
|
|
3760
|
+
<p>Evaluate ranked search results.</p>
|
|
3761
|
+
<p>Evaluate the quality of ranked search results over a set of typical search queries.</p>
|
|
3416
3762
|
|
|
3417
|
-
|
|
3763
|
+
|
|
3764
|
+
`<https://www.elastic.co/docs/api/doc/elasticsearch/v9/operation/operation-rank-eval>`_
|
|
3418
3765
|
|
|
3419
3766
|
:param requests: A set of typical search requests, together with their provided
|
|
3420
3767
|
ratings.
|
|
3421
|
-
:param index:
|
|
3768
|
+
:param index: A comma-separated list of data streams, indices, and index aliases
|
|
3422
3769
|
used to limit the request. Wildcard (`*`) expressions are supported. To target
|
|
3423
3770
|
all data streams and indices in a cluster, omit this parameter or use `_all`
|
|
3424
3771
|
or `*`.
|
|
@@ -3506,33 +3853,187 @@ class AsyncElasticsearch(BaseClient):
|
|
|
3506
3853
|
body: t.Optional[t.Dict[str, t.Any]] = None,
|
|
3507
3854
|
) -> ObjectApiResponse[t.Any]:
|
|
3508
3855
|
"""
|
|
3509
|
-
|
|
3510
|
-
|
|
3511
|
-
|
|
3512
|
-
|
|
3513
|
-
|
|
3856
|
+
.. raw:: html
|
|
3857
|
+
|
|
3858
|
+
<p>Reindex documents.</p>
|
|
3859
|
+
<p>Copy documents from a source to a destination.
|
|
3860
|
+
You can copy all documents to the destination index or reindex a subset of the documents.
|
|
3861
|
+
The source can be any existing index, alias, or data stream.
|
|
3862
|
+
The destination must differ from the source.
|
|
3863
|
+
For example, you cannot reindex a data stream into itself.</p>
|
|
3864
|
+
<p>IMPORTANT: Reindex requires <code>_source</code> to be enabled for all documents in the source.
|
|
3865
|
+
The destination should be configured as wanted before calling the reindex API.
|
|
3866
|
+
Reindex does not copy the settings from the source or its associated template.
|
|
3867
|
+
Mappings, shard counts, and replicas, for example, must be configured ahead of time.</p>
|
|
3868
|
+
<p>If the Elasticsearch security features are enabled, you must have the following security privileges:</p>
|
|
3869
|
+
<ul>
|
|
3870
|
+
<li>The <code>read</code> index privilege for the source data stream, index, or alias.</li>
|
|
3871
|
+
<li>The <code>write</code> index privilege for the destination data stream, index, or index alias.</li>
|
|
3872
|
+
<li>To automatically create a data stream or index with a reindex API request, you must have the <code>auto_configure</code>, <code>create_index</code>, or <code>manage</code> index privilege for the destination data stream, index, or alias.</li>
|
|
3873
|
+
<li>If reindexing from a remote cluster, the <code>source.remote.user</code> must have the <code>monitor</code> cluster privilege and the <code>read</code> index privilege for the source data stream, index, or alias.</li>
|
|
3874
|
+
</ul>
|
|
3875
|
+
<p>If reindexing from a remote cluster, you must explicitly allow the remote host in the <code>reindex.remote.whitelist</code> setting.
|
|
3876
|
+
Automatic data stream creation requires a matching index template with data stream enabled.</p>
|
|
3877
|
+
<p>The <code>dest</code> element can be configured like the index API to control optimistic concurrency control.
|
|
3878
|
+
Omitting <code>version_type</code> or setting it to <code>internal</code> causes Elasticsearch to blindly dump documents into the destination, overwriting any that happen to have the same ID.</p>
|
|
3879
|
+
<p>Setting <code>version_type</code> to <code>external</code> causes Elasticsearch to preserve the <code>version</code> from the source, create any documents that are missing, and update any documents that have an older version in the destination than they do in the source.</p>
|
|
3880
|
+
<p>Setting <code>op_type</code> to <code>create</code> causes the reindex API to create only missing documents in the destination.
|
|
3881
|
+
All existing documents will cause a version conflict.</p>
|
|
3882
|
+
<p>IMPORTANT: Because data streams are append-only, any reindex request to a destination data stream must have an <code>op_type</code> of <code>create</code>.
|
|
3883
|
+
A reindex can only add new documents to a destination data stream.
|
|
3884
|
+
It cannot update existing documents in a destination data stream.</p>
|
|
3885
|
+
<p>By default, version conflicts abort the reindex process.
|
|
3886
|
+
To continue reindexing if there are conflicts, set the <code>conflicts</code> request body property to <code>proceed</code>.
|
|
3887
|
+
In this case, the response includes a count of the version conflicts that were encountered.
|
|
3888
|
+
Note that the handling of other error types is unaffected by the <code>conflicts</code> property.
|
|
3889
|
+
Additionally, if you opt to count version conflicts, the operation could attempt to reindex more documents from the source than <code>max_docs</code> until it has successfully indexed <code>max_docs</code> documents into the target or it has gone through every document in the source query.</p>
|
|
3890
|
+
<p>NOTE: The reindex API makes no effort to handle ID collisions.
|
|
3891
|
+
The last document written will "win" but the order isn't usually predictable so it is not a good idea to rely on this behavior.
|
|
3892
|
+
Instead, make sure that IDs are unique by using a script.</p>
|
|
3893
|
+
<p><strong>Running reindex asynchronously</strong></p>
|
|
3894
|
+
<p>If the request contains <code>wait_for_completion=false</code>, Elasticsearch performs some preflight checks, launches the request, and returns a task you can use to cancel or get the status of the task.
|
|
3895
|
+
Elasticsearch creates a record of this task as a document at <code>_tasks/<task_id></code>.</p>
|
|
3896
|
+
<p><strong>Reindex from multiple sources</strong></p>
|
|
3897
|
+
<p>If you have many sources to reindex it is generally better to reindex them one at a time rather than using a glob pattern to pick up multiple sources.
|
|
3898
|
+
That way you can resume the process if there are any errors by removing the partially completed source and starting over.
|
|
3899
|
+
It also makes parallelizing the process fairly simple: split the list of sources to reindex and run each list in parallel.</p>
|
|
3900
|
+
<p>For example, you can use a bash script like this:</p>
|
|
3901
|
+
<pre><code>for index in i1 i2 i3 i4 i5; do
|
|
3902
|
+
curl -HContent-Type:application/json -XPOST localhost:9200/_reindex?pretty -d'{
|
|
3903
|
+
"source": {
|
|
3904
|
+
"index": "'$index'"
|
|
3905
|
+
},
|
|
3906
|
+
"dest": {
|
|
3907
|
+
"index": "'$index'-reindexed"
|
|
3908
|
+
}
|
|
3909
|
+
}'
|
|
3910
|
+
done
|
|
3911
|
+
</code></pre>
|
|
3912
|
+
<p><strong>Throttling</strong></p>
|
|
3913
|
+
<p>Set <code>requests_per_second</code> to any positive decimal number (<code>1.4</code>, <code>6</code>, <code>1000</code>, for example) to throttle the rate at which reindex issues batches of index operations.
|
|
3914
|
+
Requests are throttled by padding each batch with a wait time.
|
|
3915
|
+
To turn off throttling, set <code>requests_per_second</code> to <code>-1</code>.</p>
|
|
3916
|
+
<p>The throttling is done by waiting between batches so that the scroll that reindex uses internally can be given a timeout that takes into account the padding.
|
|
3917
|
+
The padding time is the difference between the batch size divided by the <code>requests_per_second</code> and the time spent writing.
|
|
3918
|
+
By default the batch size is <code>1000</code>, so if <code>requests_per_second</code> is set to <code>500</code>:</p>
|
|
3919
|
+
<pre><code>target_time = 1000 / 500 per second = 2 seconds
|
|
3920
|
+
wait_time = target_time - write_time = 2 seconds - .5 seconds = 1.5 seconds
|
|
3921
|
+
</code></pre>
|
|
3922
|
+
<p>Since the batch is issued as a single bulk request, large batch sizes cause Elasticsearch to create many requests and then wait for a while before starting the next set.
|
|
3923
|
+
This is "bursty" instead of "smooth".</p>
|
|
3924
|
+
<p><strong>Slicing</strong></p>
|
|
3925
|
+
<p>Reindex supports sliced scroll to parallelize the reindexing process.
|
|
3926
|
+
This parallelization can improve efficiency and provide a convenient way to break the request down into smaller parts.</p>
|
|
3927
|
+
<p>NOTE: Reindexing from remote clusters does not support manual or automatic slicing.</p>
|
|
3928
|
+
<p>You can slice a reindex request manually by providing a slice ID and total number of slices to each request.
|
|
3929
|
+
You can also let reindex automatically parallelize by using sliced scroll to slice on <code>_id</code>.
|
|
3930
|
+
The <code>slices</code> parameter specifies the number of slices to use.</p>
|
|
3931
|
+
<p>Adding <code>slices</code> to the reindex request just automates the manual process, creating sub-requests which means it has some quirks:</p>
|
|
3932
|
+
<ul>
|
|
3933
|
+
<li>You can see these requests in the tasks API. These sub-requests are "child" tasks of the task for the request with slices.</li>
|
|
3934
|
+
<li>Fetching the status of the task for the request with <code>slices</code> only contains the status of completed slices.</li>
|
|
3935
|
+
<li>These sub-requests are individually addressable for things like cancellation and rethrottling.</li>
|
|
3936
|
+
<li>Rethrottling the request with <code>slices</code> will rethrottle the unfinished sub-request proportionally.</li>
|
|
3937
|
+
<li>Canceling the request with <code>slices</code> will cancel each sub-request.</li>
|
|
3938
|
+
<li>Due to the nature of <code>slices</code>, each sub-request won't get a perfectly even portion of the documents. All documents will be addressed, but some slices may be larger than others. Expect larger slices to have a more even distribution.</li>
|
|
3939
|
+
<li>Parameters like <code>requests_per_second</code> and <code>max_docs</code> on a request with <code>slices</code> are distributed proportionally to each sub-request. Combine that with the previous point about distribution being uneven and you should conclude that using <code>max_docs</code> with <code>slices</code> might not result in exactly <code>max_docs</code> documents being reindexed.</li>
|
|
3940
|
+
<li>Each sub-request gets a slightly different snapshot of the source, though these are all taken at approximately the same time.</li>
|
|
3941
|
+
</ul>
|
|
3942
|
+
<p>If slicing automatically, setting <code>slices</code> to <code>auto</code> will choose a reasonable number for most indices.
|
|
3943
|
+
If slicing manually or otherwise tuning automatic slicing, use the following guidelines.</p>
|
|
3944
|
+
<p>Query performance is most efficient when the number of slices is equal to the number of shards in the index.
|
|
3945
|
+
If that number is large (for example, <code>500</code>), choose a lower number as too many slices will hurt performance.
|
|
3946
|
+
Setting slices higher than the number of shards generally does not improve efficiency and adds overhead.</p>
|
|
3947
|
+
<p>Indexing performance scales linearly across available resources with the number of slices.</p>
|
|
3948
|
+
<p>Whether query or indexing performance dominates the runtime depends on the documents being reindexed and cluster resources.</p>
|
|
3949
|
+
<p><strong>Modify documents during reindexing</strong></p>
|
|
3950
|
+
<p>Like <code>_update_by_query</code>, reindex operations support a script that modifies the document.
|
|
3951
|
+
Unlike <code>_update_by_query</code>, the script is allowed to modify the document's metadata.</p>
|
|
3952
|
+
<p>Just as in <code>_update_by_query</code>, you can set <code>ctx.op</code> to change the operation that is run on the destination.
|
|
3953
|
+
For example, set <code>ctx.op</code> to <code>noop</code> if your script decides that the document doesn’t have to be indexed in the destination. This "no operation" will be reported in the <code>noop</code> counter in the response body.
|
|
3954
|
+
Set <code>ctx.op</code> to <code>delete</code> if your script decides that the document must be deleted from the destination.
|
|
3955
|
+
The deletion will be reported in the <code>deleted</code> counter in the response body.
|
|
3956
|
+
Setting <code>ctx.op</code> to anything else will return an error, as will setting any other field in <code>ctx</code>.</p>
|
|
3957
|
+
<p>Think of the possibilities! Just be careful; you are able to change:</p>
|
|
3958
|
+
<ul>
|
|
3959
|
+
<li><code>_id</code></li>
|
|
3960
|
+
<li><code>_index</code></li>
|
|
3961
|
+
<li><code>_version</code></li>
|
|
3962
|
+
<li><code>_routing</code></li>
|
|
3963
|
+
</ul>
|
|
3964
|
+
<p>Setting <code>_version</code> to <code>null</code> or clearing it from the <code>ctx</code> map is just like not sending the version in an indexing request.
|
|
3965
|
+
It will cause the document to be overwritten in the destination regardless of the version on the target or the version type you use in the reindex API.</p>
|
|
3966
|
+
<p><strong>Reindex from remote</strong></p>
|
|
3967
|
+
<p>Reindex supports reindexing from a remote Elasticsearch cluster.
|
|
3968
|
+
The <code>host</code> parameter must contain a scheme, host, port, and optional path.
|
|
3969
|
+
The <code>username</code> and <code>password</code> parameters are optional and when they are present the reindex operation will connect to the remote Elasticsearch node using basic authentication.
|
|
3970
|
+
Be sure to use HTTPS when using basic authentication or the password will be sent in plain text.
|
|
3971
|
+
There are a range of settings available to configure the behavior of the HTTPS connection.</p>
|
|
3972
|
+
<p>When using Elastic Cloud, it is also possible to authenticate against the remote cluster through the use of a valid API key.
|
|
3973
|
+
Remote hosts must be explicitly allowed with the <code>reindex.remote.whitelist</code> setting.
|
|
3974
|
+
It can be set to a comma delimited list of allowed remote host and port combinations.
|
|
3975
|
+
Scheme is ignored; only the host and port are used.
|
|
3976
|
+
For example:</p>
|
|
3977
|
+
<pre><code>reindex.remote.whitelist: [otherhost:9200, another:9200, 127.0.10.*:9200, localhost:*"]
|
|
3978
|
+
</code></pre>
|
|
3979
|
+
<p>The list of allowed hosts must be configured on any nodes that will coordinate the reindex.
|
|
3980
|
+
This feature should work with remote clusters of any version of Elasticsearch.
|
|
3981
|
+
This should enable you to upgrade from any version of Elasticsearch to the current version by reindexing from a cluster of the old version.</p>
|
|
3982
|
+
<p>WARNING: Elasticsearch does not support forward compatibility across major versions.
|
|
3983
|
+
For example, you cannot reindex from a 7.x cluster into a 6.x cluster.</p>
|
|
3984
|
+
<p>To enable queries sent to older versions of Elasticsearch, the <code>query</code> parameter is sent directly to the remote host without validation or modification.</p>
|
|
3985
|
+
<p>NOTE: Reindexing from remote clusters does not support manual or automatic slicing.</p>
|
|
3986
|
+
<p>Reindexing from a remote server uses an on-heap buffer that defaults to a maximum size of 100mb.
|
|
3987
|
+
If the remote index includes very large documents you'll need to use a smaller batch size.
|
|
3988
|
+
It is also possible to set the socket read timeout on the remote connection with the <code>socket_timeout</code> field and the connection timeout with the <code>connect_timeout</code> field.
|
|
3989
|
+
Both default to 30 seconds.</p>
|
|
3990
|
+
<p><strong>Configuring SSL parameters</strong></p>
|
|
3991
|
+
<p>Reindex from remote supports configurable SSL settings.
|
|
3992
|
+
These must be specified in the <code>elasticsearch.yml</code> file, with the exception of the secure settings, which you add in the Elasticsearch keystore.
|
|
3993
|
+
It is not possible to configure SSL in the body of the reindex request.</p>
|
|
3994
|
+
|
|
3995
|
+
|
|
3996
|
+
`<https://www.elastic.co/docs/api/doc/elasticsearch/v9/operation/operation-reindex>`_
|
|
3514
3997
|
|
|
3515
3998
|
:param dest: The destination you are copying to.
|
|
3516
3999
|
:param source: The source you are copying from.
|
|
3517
|
-
:param conflicts:
|
|
3518
|
-
|
|
4000
|
+
:param conflicts: Indicates whether to continue reindexing even when there are
|
|
4001
|
+
conflicts.
|
|
4002
|
+
:param max_docs: The maximum number of documents to reindex. By default, all
|
|
4003
|
+
documents are reindexed. If it is a value less then or equal to `scroll_size`,
|
|
4004
|
+
a scroll will not be used to retrieve the results for the operation. If `conflicts`
|
|
4005
|
+
is set to `proceed`, the reindex operation could attempt to reindex more
|
|
4006
|
+
documents from the source than `max_docs` until it has successfully indexed
|
|
4007
|
+
`max_docs` documents into the target or it has gone through every document
|
|
4008
|
+
in the source query.
|
|
3519
4009
|
:param refresh: If `true`, the request refreshes affected shards to make this
|
|
3520
4010
|
operation visible to search.
|
|
3521
4011
|
:param requests_per_second: The throttle for this request in sub-requests per
|
|
3522
|
-
second.
|
|
4012
|
+
second. By default, there is no throttle.
|
|
3523
4013
|
:param require_alias: If `true`, the destination must be an index alias.
|
|
3524
4014
|
:param script: The script to run to update the document source or metadata when
|
|
3525
4015
|
reindexing.
|
|
3526
|
-
:param scroll:
|
|
3527
|
-
for scrolled search.
|
|
4016
|
+
:param scroll: The period of time that a consistent view of the index should
|
|
4017
|
+
be maintained for scrolled search.
|
|
3528
4018
|
:param size:
|
|
3529
|
-
:param slices: The number of slices this task should be divided into.
|
|
3530
|
-
to
|
|
3531
|
-
|
|
3532
|
-
|
|
4019
|
+
:param slices: The number of slices this task should be divided into. It defaults
|
|
4020
|
+
to one slice, which means the task isn't sliced into subtasks. Reindex supports
|
|
4021
|
+
sliced scroll to parallelize the reindexing process. This parallelization
|
|
4022
|
+
can improve efficiency and provide a convenient way to break the request
|
|
4023
|
+
down into smaller parts. NOTE: Reindexing from remote clusters does not support
|
|
4024
|
+
manual or automatic slicing. If set to `auto`, Elasticsearch chooses the
|
|
4025
|
+
number of slices to use. This setting will use one slice per shard, up to
|
|
4026
|
+
a certain limit. If there are multiple sources, it will choose the number
|
|
4027
|
+
of slices based on the index or backing index with the smallest number of
|
|
4028
|
+
shards.
|
|
4029
|
+
:param timeout: The period each indexing waits for automatic index creation,
|
|
4030
|
+
dynamic mapping updates, and waiting for active shards. By default, Elasticsearch
|
|
4031
|
+
waits for at least one minute before failing. The actual wait time could
|
|
4032
|
+
be longer, particularly when multiple waits occur.
|
|
3533
4033
|
:param wait_for_active_shards: The number of shard copies that must be active
|
|
3534
|
-
before proceeding with the operation. Set to `all` or any positive integer
|
|
3535
|
-
up to the total number of shards in the index (`number_of_replicas+1`).
|
|
4034
|
+
before proceeding with the operation. Set it to `all` or any positive integer
|
|
4035
|
+
up to the total number of shards in the index (`number_of_replicas+1`). The
|
|
4036
|
+
default value is one, which means it waits for each primary shard to be active.
|
|
3536
4037
|
:param wait_for_completion: If `true`, the request blocks until the operation
|
|
3537
4038
|
is complete.
|
|
3538
4039
|
"""
|
|
@@ -3604,14 +4105,24 @@ class AsyncElasticsearch(BaseClient):
|
|
|
3604
4105
|
requests_per_second: t.Optional[float] = None,
|
|
3605
4106
|
) -> ObjectApiResponse[t.Any]:
|
|
3606
4107
|
"""
|
|
3607
|
-
|
|
3608
|
-
|
|
4108
|
+
.. raw:: html
|
|
4109
|
+
|
|
4110
|
+
<p>Throttle a reindex operation.</p>
|
|
4111
|
+
<p>Change the number of requests per second for a particular reindex operation.
|
|
4112
|
+
For example:</p>
|
|
4113
|
+
<pre><code>POST _reindex/r1A2WoRbTwKZ516z6NEs5A:36619/_rethrottle?requests_per_second=-1
|
|
4114
|
+
</code></pre>
|
|
4115
|
+
<p>Rethrottling that speeds up the query takes effect immediately.
|
|
4116
|
+
Rethrottling that slows down the query will take effect after completing the current batch.
|
|
4117
|
+
This behavior prevents scroll timeouts.</p>
|
|
3609
4118
|
|
|
3610
|
-
`<https://www.elastic.co/guide/en/elasticsearch/reference/8.17/docs-reindex.html>`_
|
|
3611
4119
|
|
|
3612
|
-
|
|
4120
|
+
`<https://www.elastic.co/docs/api/doc/elasticsearch/v9/operation/operation-reindex>`_
|
|
4121
|
+
|
|
4122
|
+
:param task_id: The task identifier, which can be found by using the tasks API.
|
|
3613
4123
|
:param requests_per_second: The throttle for this request in sub-requests per
|
|
3614
|
-
second.
|
|
4124
|
+
second. It can be either `-1` to turn off throttling or any decimal number
|
|
4125
|
+
like `1.7` or `12` to throttle to that level.
|
|
3615
4126
|
"""
|
|
3616
4127
|
if task_id in SKIP_IN_PATH:
|
|
3617
4128
|
raise ValueError("Empty value passed for parameter 'task_id'")
|
|
@@ -3652,21 +4163,25 @@ class AsyncElasticsearch(BaseClient):
|
|
|
3652
4163
|
human: t.Optional[bool] = None,
|
|
3653
4164
|
params: t.Optional[t.Mapping[str, t.Any]] = None,
|
|
3654
4165
|
pretty: t.Optional[bool] = None,
|
|
3655
|
-
source: t.Optional[str] = None,
|
|
4166
|
+
source: t.Optional[t.Union[str, t.Mapping[str, t.Any]]] = None,
|
|
3656
4167
|
body: t.Optional[t.Dict[str, t.Any]] = None,
|
|
3657
4168
|
) -> ObjectApiResponse[t.Any]:
|
|
3658
4169
|
"""
|
|
3659
|
-
|
|
4170
|
+
.. raw:: html
|
|
3660
4171
|
|
|
3661
|
-
|
|
4172
|
+
<p>Render a search template.</p>
|
|
4173
|
+
<p>Render a search template as a search request body.</p>
|
|
3662
4174
|
|
|
3663
|
-
|
|
4175
|
+
|
|
4176
|
+
`<https://www.elastic.co/docs/api/doc/elasticsearch/v9/operation/operation-render-search-template>`_
|
|
4177
|
+
|
|
4178
|
+
:param id: The ID of the search template to render. If no `source` is specified,
|
|
3664
4179
|
this or the `id` request body parameter is required.
|
|
3665
4180
|
:param file:
|
|
3666
4181
|
:param params: Key-value pairs used to replace Mustache variables in the template.
|
|
3667
4182
|
The key is the variable name. The value is the variable value.
|
|
3668
|
-
:param source: An inline search template.
|
|
3669
|
-
search API's request body. These parameters also support Mustache variables.
|
|
4183
|
+
:param source: An inline search template. It supports the same parameters as
|
|
4184
|
+
the search API's request body. These parameters also support Mustache variables.
|
|
3670
4185
|
If no `id` or `<templated-id>` is specified, this parameter is required.
|
|
3671
4186
|
"""
|
|
3672
4187
|
__path_parts: t.Dict[str, str]
|
|
@@ -3715,7 +4230,24 @@ class AsyncElasticsearch(BaseClient):
|
|
|
3715
4230
|
async def scripts_painless_execute(
|
|
3716
4231
|
self,
|
|
3717
4232
|
*,
|
|
3718
|
-
context: t.Optional[
|
|
4233
|
+
context: t.Optional[
|
|
4234
|
+
t.Union[
|
|
4235
|
+
str,
|
|
4236
|
+
t.Literal[
|
|
4237
|
+
"boolean_field",
|
|
4238
|
+
"composite_field",
|
|
4239
|
+
"date_field",
|
|
4240
|
+
"double_field",
|
|
4241
|
+
"filter",
|
|
4242
|
+
"geo_point_field",
|
|
4243
|
+
"ip_field",
|
|
4244
|
+
"keyword_field",
|
|
4245
|
+
"long_field",
|
|
4246
|
+
"painless_test",
|
|
4247
|
+
"score",
|
|
4248
|
+
],
|
|
4249
|
+
]
|
|
4250
|
+
] = None,
|
|
3719
4251
|
context_setup: t.Optional[t.Mapping[str, t.Any]] = None,
|
|
3720
4252
|
error_trace: t.Optional[bool] = None,
|
|
3721
4253
|
filter_path: t.Optional[t.Union[str, t.Sequence[str]]] = None,
|
|
@@ -3725,13 +4257,24 @@ class AsyncElasticsearch(BaseClient):
|
|
|
3725
4257
|
body: t.Optional[t.Dict[str, t.Any]] = None,
|
|
3726
4258
|
) -> ObjectApiResponse[t.Any]:
|
|
3727
4259
|
"""
|
|
3728
|
-
|
|
4260
|
+
.. raw:: html
|
|
3729
4261
|
|
|
3730
|
-
|
|
4262
|
+
<p>Run a script.</p>
|
|
4263
|
+
<p>Runs a script and returns a result.
|
|
4264
|
+
Use this API to build and test scripts, such as when defining a script for a runtime field.
|
|
4265
|
+
This API requires very few dependencies and is especially useful if you don't have permissions to write documents on a cluster.</p>
|
|
4266
|
+
<p>The API uses several <em>contexts</em>, which control how scripts are run, what variables are available at runtime, and what the return type is.</p>
|
|
4267
|
+
<p>Each context requires a script, but additional parameters depend on the context you're using for that script.</p>
|
|
3731
4268
|
|
|
3732
|
-
|
|
3733
|
-
|
|
3734
|
-
|
|
4269
|
+
|
|
4270
|
+
`<https://www.elastic.co/docs/reference/scripting-languages/painless/painless-api-examples>`_
|
|
4271
|
+
|
|
4272
|
+
:param context: The context that the script should run in. NOTE: Result ordering
|
|
4273
|
+
in the field contexts is not guaranteed.
|
|
4274
|
+
:param context_setup: Additional parameters for the `context`. NOTE: This parameter
|
|
4275
|
+
is required for all contexts except `painless_test`, which is the default
|
|
4276
|
+
if no value is provided for `context`.
|
|
4277
|
+
:param script: The Painless script to run.
|
|
3735
4278
|
"""
|
|
3736
4279
|
__path_parts: t.Dict[str, str] = {}
|
|
3737
4280
|
__path = "/_scripts/painless/_execute"
|
|
@@ -3783,30 +4326,27 @@ class AsyncElasticsearch(BaseClient):
|
|
|
3783
4326
|
body: t.Optional[t.Dict[str, t.Any]] = None,
|
|
3784
4327
|
) -> ObjectApiResponse[t.Any]:
|
|
3785
4328
|
"""
|
|
3786
|
-
|
|
3787
|
-
|
|
3788
|
-
|
|
3789
|
-
|
|
3790
|
-
|
|
3791
|
-
|
|
3792
|
-
|
|
3793
|
-
|
|
3794
|
-
|
|
3795
|
-
|
|
3796
|
-
|
|
3797
|
-
|
|
3798
|
-
|
|
3799
|
-
|
|
3800
|
-
|
|
3801
|
-
|
|
3802
|
-
|
|
3803
|
-
`<https://www.elastic.co/guide/en/elasticsearch/reference/8.17/search-request-body.html#request-body-search-scroll>`_
|
|
3804
|
-
|
|
3805
|
-
:param scroll_id: Scroll ID of the search.
|
|
4329
|
+
.. raw:: html
|
|
4330
|
+
|
|
4331
|
+
<p>Run a scrolling search.</p>
|
|
4332
|
+
<p>IMPORTANT: The scroll API is no longer recommend for deep pagination. If you need to preserve the index state while paging through more than 10,000 hits, use the <code>search_after</code> parameter with a point in time (PIT).</p>
|
|
4333
|
+
<p>The scroll API gets large sets of results from a single scrolling search request.
|
|
4334
|
+
To get the necessary scroll ID, submit a search API request that includes an argument for the <code>scroll</code> query parameter.
|
|
4335
|
+
The <code>scroll</code> parameter indicates how long Elasticsearch should retain the search context for the request.
|
|
4336
|
+
The search response returns a scroll ID in the <code>_scroll_id</code> response body parameter.
|
|
4337
|
+
You can then use the scroll ID with the scroll API to retrieve the next batch of results for the request.
|
|
4338
|
+
If the Elasticsearch security features are enabled, the access to the results of a specific scroll ID is restricted to the user or API key that submitted the search.</p>
|
|
4339
|
+
<p>You can also use the scroll API to specify a new scroll parameter that extends or shortens the retention period for the search context.</p>
|
|
4340
|
+
<p>IMPORTANT: Results from a scrolling search reflect the state of the index at the time of the initial search request. Subsequent indexing or document changes only affect later search and scroll requests.</p>
|
|
4341
|
+
|
|
4342
|
+
|
|
4343
|
+
`<https://www.elastic.co/docs/api/doc/elasticsearch/v9/operation/operation-scroll>`_
|
|
4344
|
+
|
|
4345
|
+
:param scroll_id: The scroll ID of the search.
|
|
3806
4346
|
:param rest_total_hits_as_int: If true, the API response’s hit.total property
|
|
3807
4347
|
is returned as an integer. If false, the API response’s hit.total property
|
|
3808
4348
|
is returned as an object.
|
|
3809
|
-
:param scroll:
|
|
4349
|
+
:param scroll: The period to retain the search context for scrolling.
|
|
3810
4350
|
"""
|
|
3811
4351
|
if scroll_id is None and body is None:
|
|
3812
4352
|
raise ValueError("Empty value passed for parameter 'scroll_id'")
|
|
@@ -3931,7 +4471,6 @@ class AsyncElasticsearch(BaseClient):
|
|
|
3931
4471
|
] = None,
|
|
3932
4472
|
lenient: t.Optional[bool] = None,
|
|
3933
4473
|
max_concurrent_shard_requests: t.Optional[int] = None,
|
|
3934
|
-
min_compatible_shard_node: t.Optional[str] = None,
|
|
3935
4474
|
min_score: t.Optional[float] = None,
|
|
3936
4475
|
pit: t.Optional[t.Mapping[str, t.Any]] = None,
|
|
3937
4476
|
post_filter: t.Optional[t.Mapping[str, t.Any]] = None,
|
|
@@ -3953,7 +4492,7 @@ class AsyncElasticsearch(BaseClient):
|
|
|
3953
4492
|
script_fields: t.Optional[t.Mapping[str, t.Mapping[str, t.Any]]] = None,
|
|
3954
4493
|
scroll: t.Optional[t.Union[str, t.Literal[-1], t.Literal[0]]] = None,
|
|
3955
4494
|
search_after: t.Optional[
|
|
3956
|
-
t.Sequence[t.Union[None, bool, float, int, str
|
|
4495
|
+
t.Sequence[t.Union[None, bool, float, int, str]]
|
|
3957
4496
|
] = None,
|
|
3958
4497
|
search_type: t.Optional[
|
|
3959
4498
|
t.Union[str, t.Literal["dfs_query_then_fetch", "query_then_fetch"]]
|
|
@@ -3988,15 +4527,29 @@ class AsyncElasticsearch(BaseClient):
|
|
|
3988
4527
|
body: t.Optional[t.Dict[str, t.Any]] = None,
|
|
3989
4528
|
) -> ObjectApiResponse[t.Any]:
|
|
3990
4529
|
"""
|
|
3991
|
-
|
|
3992
|
-
|
|
3993
|
-
|
|
4530
|
+
.. raw:: html
|
|
4531
|
+
|
|
4532
|
+
<p>Run a search.</p>
|
|
4533
|
+
<p>Get search hits that match the query defined in the request.
|
|
4534
|
+
You can provide search queries using the <code>q</code> query string parameter or the request body.
|
|
4535
|
+
If both are specified, only the query parameter is used.</p>
|
|
4536
|
+
<p>If the Elasticsearch security features are enabled, you must have the read index privilege for the target data stream, index, or alias. For cross-cluster search, refer to the documentation about configuring CCS privileges.
|
|
4537
|
+
To search a point in time (PIT) for an alias, you must have the <code>read</code> index privilege for the alias's data streams or indices.</p>
|
|
4538
|
+
<p><strong>Search slicing</strong></p>
|
|
4539
|
+
<p>When paging through a large number of documents, it can be helpful to split the search into multiple slices to consume them independently with the <code>slice</code> and <code>pit</code> properties.
|
|
4540
|
+
By default the splitting is done first on the shards, then locally on each shard.
|
|
4541
|
+
The local splitting partitions the shard into contiguous ranges based on Lucene document IDs.</p>
|
|
4542
|
+
<p>For instance if the number of shards is equal to 2 and you request 4 slices, the slices 0 and 2 are assigned to the first shard and the slices 1 and 3 are assigned to the second shard.</p>
|
|
4543
|
+
<p>IMPORTANT: The same point-in-time ID should be used for all slices.
|
|
4544
|
+
If different PIT IDs are used, slices can overlap and miss documents.
|
|
4545
|
+
This situation can occur because the splitting criterion is based on Lucene document IDs, which are not stable across changes to the index.</p>
|
|
4546
|
+
|
|
4547
|
+
|
|
4548
|
+
`<https://www.elastic.co/docs/api/doc/elasticsearch/v9/operation/operation-search>`_
|
|
3994
4549
|
|
|
3995
|
-
|
|
3996
|
-
|
|
3997
|
-
|
|
3998
|
-
Supports wildcards (`*`). To search all data streams and indices, omit this
|
|
3999
|
-
parameter or use `*` or `_all`.
|
|
4550
|
+
:param index: A comma-separated list of data streams, indices, and aliases to
|
|
4551
|
+
search. It supports wildcards (`*`). To search all data streams and indices,
|
|
4552
|
+
omit this parameter or use `*` or `_all`.
|
|
4000
4553
|
:param aggregations: Defines the aggregations that are run as part of the search
|
|
4001
4554
|
request.
|
|
4002
4555
|
:param aggs: Defines the aggregations that are run as part of the search request.
|
|
@@ -4005,45 +4558,46 @@ class AsyncElasticsearch(BaseClient):
|
|
|
4005
4558
|
This behavior applies even if the request targets other open indices. For
|
|
4006
4559
|
example, a request targeting `foo*,bar*` returns an error if an index starts
|
|
4007
4560
|
with `foo` but no index starts with `bar`.
|
|
4008
|
-
:param allow_partial_search_results: If true
|
|
4009
|
-
|
|
4010
|
-
with no partial results.
|
|
4011
|
-
|
|
4012
|
-
|
|
4013
|
-
|
|
4014
|
-
|
|
4561
|
+
:param allow_partial_search_results: If `true` and there are shard request timeouts
|
|
4562
|
+
or shard failures, the request returns partial results. If `false`, it returns
|
|
4563
|
+
an error with no partial results. To override the default behavior, you can
|
|
4564
|
+
set the `search.default_allow_partial_results` cluster setting to `false`.
|
|
4565
|
+
:param analyze_wildcard: If `true`, wildcard and prefix queries are analyzed.
|
|
4566
|
+
This parameter can be used only when the `q` query string parameter is specified.
|
|
4567
|
+
:param analyzer: The analyzer to use for the query string. This parameter can
|
|
4568
|
+
be used only when the `q` query string parameter is specified.
|
|
4015
4569
|
:param batched_reduce_size: The number of shard results that should be reduced
|
|
4016
|
-
at once on the coordinating node.
|
|
4017
|
-
|
|
4018
|
-
|
|
4019
|
-
:param ccs_minimize_roundtrips: If true
|
|
4020
|
-
node and the remote clusters are minimized when
|
|
4570
|
+
at once on the coordinating node. If the potential number of shards in the
|
|
4571
|
+
request can be large, this value should be used as a protection mechanism
|
|
4572
|
+
to reduce the memory overhead per search request.
|
|
4573
|
+
:param ccs_minimize_roundtrips: If `true`, network round-trips between the coordinating
|
|
4574
|
+
node and the remote clusters are minimized when running cross-cluster search
|
|
4021
4575
|
(CCS) requests.
|
|
4022
4576
|
:param collapse: Collapses search results the values of the specified field.
|
|
4023
|
-
:param default_operator: The default operator for query string query: AND
|
|
4024
|
-
OR
|
|
4025
|
-
specified.
|
|
4026
|
-
:param df: Field to use as default where no field prefix is given in the query
|
|
4027
|
-
string. This parameter can only be used when the q query string parameter
|
|
4577
|
+
:param default_operator: The default operator for the query string query: `AND`
|
|
4578
|
+
or `OR`. This parameter can be used only when the `q` query string parameter
|
|
4028
4579
|
is specified.
|
|
4029
|
-
:param
|
|
4030
|
-
|
|
4031
|
-
|
|
4032
|
-
:param
|
|
4033
|
-
|
|
4034
|
-
|
|
4035
|
-
|
|
4036
|
-
|
|
4037
|
-
|
|
4580
|
+
:param df: The field to use as a default when no field prefix is given in the
|
|
4581
|
+
query string. This parameter can be used only when the `q` query string parameter
|
|
4582
|
+
is specified.
|
|
4583
|
+
:param docvalue_fields: An array of wildcard (`*`) field patterns. The request
|
|
4584
|
+
returns doc values for field names matching these patterns in the `hits.fields`
|
|
4585
|
+
property of the response.
|
|
4586
|
+
:param expand_wildcards: The type of index that wildcard patterns can match.
|
|
4587
|
+
If the request can target data streams, this argument determines whether
|
|
4588
|
+
wildcard expressions match hidden data streams. It supports comma-separated
|
|
4589
|
+
values such as `open,hidden`.
|
|
4590
|
+
:param explain: If `true`, the request returns detailed information about score
|
|
4591
|
+
computation as part of a hit.
|
|
4038
4592
|
:param ext: Configuration of search extensions defined by Elasticsearch plugins.
|
|
4039
|
-
:param fields:
|
|
4040
|
-
field names matching these patterns in the `hits.fields` property
|
|
4041
|
-
response.
|
|
4593
|
+
:param fields: An array of wildcard (`*`) field patterns. The request returns
|
|
4594
|
+
values for field names matching these patterns in the `hits.fields` property
|
|
4595
|
+
of the response.
|
|
4042
4596
|
:param force_synthetic_source: Should this request force synthetic _source? Use
|
|
4043
4597
|
this to test if the mapping supports synthetic _source and to get a sense
|
|
4044
4598
|
of the worst case performance. Fetches with this enabled will be slower the
|
|
4045
4599
|
enabling synthetic source natively in the index.
|
|
4046
|
-
:param from_:
|
|
4600
|
+
:param from_: The starting document offset, which must be non-negative. By default,
|
|
4047
4601
|
you cannot page through more than 10,000 hits using the `from` and `size`
|
|
4048
4602
|
parameters. To page through more hits, use the `search_after` parameter.
|
|
4049
4603
|
:param highlight: Specifies the highlighter to use for retrieving highlighted
|
|
@@ -4052,95 +4606,101 @@ class AsyncElasticsearch(BaseClient):
|
|
|
4052
4606
|
be ignored when frozen.
|
|
4053
4607
|
:param ignore_unavailable: If `false`, the request returns an error if it targets
|
|
4054
4608
|
a missing or closed index.
|
|
4055
|
-
:param include_named_queries_score:
|
|
4056
|
-
|
|
4057
|
-
|
|
4058
|
-
|
|
4059
|
-
|
|
4060
|
-
|
|
4061
|
-
|
|
4062
|
-
|
|
4063
|
-
|
|
4609
|
+
:param include_named_queries_score: If `true`, the response includes the score
|
|
4610
|
+
contribution from any named queries. This functionality reruns each named
|
|
4611
|
+
query on every hit in a search response. Typically, this adds a small overhead
|
|
4612
|
+
to a request. However, using computationally expensive named queries on a
|
|
4613
|
+
large number of hits may add significant overhead.
|
|
4614
|
+
:param indices_boost: Boost the `_score` of documents from specified indices.
|
|
4615
|
+
The boost value is the factor by which scores are multiplied. A boost value
|
|
4616
|
+
greater than `1.0` increases the score. A boost value between `0` and `1.0`
|
|
4617
|
+
decreases the score.
|
|
4618
|
+
:param knn: The approximate kNN search to run.
|
|
4064
4619
|
:param lenient: If `true`, format-based query failures (such as providing text
|
|
4065
4620
|
to a numeric field) in the query string will be ignored. This parameter can
|
|
4066
|
-
|
|
4067
|
-
:param max_concurrent_shard_requests:
|
|
4068
|
-
|
|
4069
|
-
|
|
4070
|
-
|
|
4071
|
-
:param
|
|
4072
|
-
|
|
4073
|
-
|
|
4074
|
-
|
|
4075
|
-
:param pit: Limits the search to a point in time (PIT). If you provide a PIT,
|
|
4621
|
+
be used only when the `q` query string parameter is specified.
|
|
4622
|
+
:param max_concurrent_shard_requests: The number of concurrent shard requests
|
|
4623
|
+
per node that the search runs concurrently. This value should be used to
|
|
4624
|
+
limit the impact of the search on the cluster in order to limit the number
|
|
4625
|
+
of concurrent shard requests.
|
|
4626
|
+
:param min_score: The minimum `_score` for matching documents. Documents with
|
|
4627
|
+
a lower `_score` are not included in search results and results collected
|
|
4628
|
+
by aggregations.
|
|
4629
|
+
:param pit: Limit the search to a point in time (PIT). If you provide a PIT,
|
|
4076
4630
|
you cannot specify an `<index>` in the request path.
|
|
4077
4631
|
:param post_filter: Use the `post_filter` parameter to filter search results.
|
|
4078
4632
|
The search hits are filtered after the aggregations are calculated. A post
|
|
4079
4633
|
filter has no impact on the aggregation results.
|
|
4080
|
-
:param pre_filter_shard_size:
|
|
4081
|
-
|
|
4082
|
-
|
|
4083
|
-
|
|
4084
|
-
|
|
4085
|
-
|
|
4086
|
-
|
|
4087
|
-
is met:
|
|
4088
|
-
or more read-only index
|
|
4634
|
+
:param pre_filter_shard_size: A threshold that enforces a pre-filter roundtrip
|
|
4635
|
+
to prefilter search shards based on query rewriting if the number of shards
|
|
4636
|
+
the search request expands to exceeds the threshold. This filter roundtrip
|
|
4637
|
+
can limit the number of shards significantly if for instance a shard can
|
|
4638
|
+
not match any documents based on its rewrite method (if date filters are
|
|
4639
|
+
mandatory to match but the shard bounds and the query are disjoint). When
|
|
4640
|
+
unspecified, the pre-filter phase is executed if any of these conditions
|
|
4641
|
+
is met: * The request targets more than 128 shards. * The request targets
|
|
4642
|
+
one or more read-only index. * The primary sort of the query targets an indexed
|
|
4089
4643
|
field.
|
|
4090
|
-
:param preference:
|
|
4644
|
+
:param preference: The nodes and shards used for the search. By default, Elasticsearch
|
|
4091
4645
|
selects from eligible nodes and shards using adaptive replica selection,
|
|
4092
|
-
accounting for allocation awareness. Valid values are: `_only_local` to
|
|
4093
|
-
the search only on shards on the local node
|
|
4094
|
-
the search on shards on the local node, or if not, select shards using
|
|
4095
|
-
default method
|
|
4096
|
-
the specified nodes IDs
|
|
4097
|
-
selected node, use shards on those nodes using the default method
|
|
4098
|
-
|
|
4099
|
-
|
|
4100
|
-
|
|
4101
|
-
|
|
4102
|
-
|
|
4103
|
-
|
|
4104
|
-
|
|
4646
|
+
accounting for allocation awareness. Valid values are: * `_only_local` to
|
|
4647
|
+
run the search only on shards on the local node. * `_local` to, if possible,
|
|
4648
|
+
run the search on shards on the local node, or if not, select shards using
|
|
4649
|
+
the default method. * `_only_nodes:<node-id>,<node-id>` to run the search
|
|
4650
|
+
on only the specified nodes IDs. If suitable shards exist on more than one
|
|
4651
|
+
selected node, use shards on those nodes using the default method. If none
|
|
4652
|
+
of the specified nodes are available, select shards from any available node
|
|
4653
|
+
using the default method. * `_prefer_nodes:<node-id>,<node-id>` to if possible,
|
|
4654
|
+
run the search on the specified nodes IDs. If not, select shards using the
|
|
4655
|
+
default method. `_shards:<shard>,<shard>` to run the search only on the specified
|
|
4656
|
+
shards. You can combine this value with other `preference` values. However,
|
|
4657
|
+
the `_shards` value must come first. For example: `_shards:2,3|_local`. `<custom-string>`
|
|
4658
|
+
(any string that does not start with `_`) to route searches with the same
|
|
4659
|
+
`<custom-string>` to the same shards in the same order.
|
|
4105
4660
|
:param profile: Set to `true` to return detailed timing information about the
|
|
4106
4661
|
execution of individual components in a search request. NOTE: This is a debugging
|
|
4107
4662
|
tool and adds significant overhead to search execution.
|
|
4108
|
-
:param q:
|
|
4109
|
-
|
|
4110
|
-
|
|
4111
|
-
|
|
4112
|
-
|
|
4663
|
+
:param q: A query in the Lucene query string syntax. Query parameter searches
|
|
4664
|
+
do not support the full Elasticsearch Query DSL but are handy for testing.
|
|
4665
|
+
IMPORTANT: This parameter overrides the query parameter in the request body.
|
|
4666
|
+
If both parameters are specified, documents matching the query request body
|
|
4667
|
+
parameter are not returned.
|
|
4668
|
+
:param query: The search definition using the Query DSL.
|
|
4669
|
+
:param rank: The Reciprocal Rank Fusion (RRF) to use.
|
|
4113
4670
|
:param request_cache: If `true`, the caching of search results is enabled for
|
|
4114
|
-
requests where `size` is `0`.
|
|
4671
|
+
requests where `size` is `0`. It defaults to index level settings.
|
|
4115
4672
|
:param rescore: Can be used to improve precision by reordering just the top (for
|
|
4116
4673
|
example 100 - 500) documents returned by the `query` and `post_filter` phases.
|
|
4117
4674
|
:param rest_total_hits_as_int: Indicates whether `hits.total` should be rendered
|
|
4118
4675
|
as an integer or an object in the rest search response.
|
|
4119
4676
|
:param retriever: A retriever is a specification to describe top documents returned
|
|
4120
4677
|
from a search. A retriever replaces other elements of the search API that
|
|
4121
|
-
also return top documents such as query and knn
|
|
4122
|
-
:param routing:
|
|
4123
|
-
|
|
4124
|
-
|
|
4678
|
+
also return top documents such as `query` and `knn`.
|
|
4679
|
+
:param routing: A custom value that is used to route operations to a specific
|
|
4680
|
+
shard.
|
|
4681
|
+
:param runtime_mappings: One or more runtime fields in the search request. These
|
|
4682
|
+
fields take precedence over mapped fields with the same name.
|
|
4125
4683
|
:param script_fields: Retrieve a script evaluation (based on different fields)
|
|
4126
4684
|
for each hit.
|
|
4127
|
-
:param scroll:
|
|
4128
|
-
|
|
4129
|
-
|
|
4685
|
+
:param scroll: The period to retain the search context for scrolling. By default,
|
|
4686
|
+
this value cannot exceed `1d` (24 hours). You can change this limit by using
|
|
4687
|
+
the `search.max_keep_alive` cluster-level setting.
|
|
4130
4688
|
:param search_after: Used to retrieve the next page of hits using a set of sort
|
|
4131
4689
|
values from the previous page.
|
|
4132
|
-
:param search_type:
|
|
4133
|
-
scoring.
|
|
4134
|
-
:param seq_no_primary_term: If `true`, returns sequence number and
|
|
4135
|
-
of the last modification of each hit.
|
|
4136
|
-
:param size: The number of hits to return. By default,
|
|
4137
|
-
more than 10,000 hits using the `from` and `size`
|
|
4138
|
-
more hits, use the `search_after`
|
|
4139
|
-
:param slice:
|
|
4140
|
-
|
|
4690
|
+
:param search_type: Indicates how distributed term frequencies are calculated
|
|
4691
|
+
for relevance scoring.
|
|
4692
|
+
:param seq_no_primary_term: If `true`, the request returns sequence number and
|
|
4693
|
+
primary term of the last modification of each hit.
|
|
4694
|
+
:param size: The number of hits to return, which must not be negative. By default,
|
|
4695
|
+
you cannot page through more than 10,000 hits using the `from` and `size`
|
|
4696
|
+
parameters. To page through more hits, use the `search_after` property.
|
|
4697
|
+
:param slice: Split a scrolled search into multiple slices that can be consumed
|
|
4698
|
+
independently.
|
|
4141
4699
|
:param sort: A comma-separated list of <field>:<direction> pairs.
|
|
4142
|
-
:param source:
|
|
4143
|
-
|
|
4700
|
+
:param source: The source fields that are returned for matching documents. These
|
|
4701
|
+
fields are returned in the `hits._source` property of the search response.
|
|
4702
|
+
If the `stored_fields` property is specified, the `_source` property defaults
|
|
4703
|
+
to `false`. Otherwise, it defaults to `true`.
|
|
4144
4704
|
:param source_excludes: A comma-separated list of source fields to exclude from
|
|
4145
4705
|
the response. You can also use this parameter to exclude fields from the
|
|
4146
4706
|
subset specified in `_source_includes` query parameter. If the `_source`
|
|
@@ -4150,45 +4710,46 @@ class AsyncElasticsearch(BaseClient):
|
|
|
4150
4710
|
returned. You can exclude fields from this subset using the `_source_excludes`
|
|
4151
4711
|
query parameter. If the `_source` parameter is `false`, this parameter is
|
|
4152
4712
|
ignored.
|
|
4153
|
-
:param stats:
|
|
4713
|
+
:param stats: The stats groups to associate with the search. Each group maintains
|
|
4154
4714
|
a statistics aggregation for its associated searches. You can retrieve these
|
|
4155
4715
|
stats using the indices stats API.
|
|
4156
|
-
:param stored_fields:
|
|
4157
|
-
fields are specified, no stored fields are included in the
|
|
4158
|
-
field is specified, the `_source`
|
|
4159
|
-
pass `_source: true` to return both source fields and stored
|
|
4160
|
-
search response.
|
|
4716
|
+
:param stored_fields: A comma-separated list of stored fields to return as part
|
|
4717
|
+
of a hit. If no fields are specified, no stored fields are included in the
|
|
4718
|
+
response. If this field is specified, the `_source` property defaults to
|
|
4719
|
+
`false`. You can pass `_source: true` to return both source fields and stored
|
|
4720
|
+
fields in the search response.
|
|
4161
4721
|
:param suggest: Defines a suggester that provides similar looking terms based
|
|
4162
4722
|
on a provided text.
|
|
4163
|
-
:param suggest_field:
|
|
4164
|
-
:param suggest_mode:
|
|
4165
|
-
|
|
4166
|
-
:param suggest_size:
|
|
4167
|
-
be used when the `suggest_field` and `suggest_text` query string parameters
|
|
4723
|
+
:param suggest_field: The field to use for suggestions.
|
|
4724
|
+
:param suggest_mode: The suggest mode. This parameter can be used only when the
|
|
4725
|
+
`suggest_field` and `suggest_text` query string parameters are specified.
|
|
4726
|
+
:param suggest_size: The number of suggestions to return. This parameter can
|
|
4727
|
+
be used only when the `suggest_field` and `suggest_text` query string parameters
|
|
4168
4728
|
are specified.
|
|
4169
4729
|
:param suggest_text: The source text for which the suggestions should be returned.
|
|
4170
|
-
This parameter can
|
|
4730
|
+
This parameter can be used only when the `suggest_field` and `suggest_text`
|
|
4171
4731
|
query string parameters are specified.
|
|
4172
|
-
:param terminate_after:
|
|
4732
|
+
:param terminate_after: The maximum number of documents to collect for each shard.
|
|
4173
4733
|
If a query reaches this limit, Elasticsearch terminates the query early.
|
|
4174
|
-
Elasticsearch collects documents before sorting. Use with caution.
|
|
4175
|
-
applies this
|
|
4176
|
-
let Elasticsearch perform early termination automatically. Avoid
|
|
4177
|
-
this
|
|
4178
|
-
across multiple data tiers. If set to `0` (default), the query does
|
|
4179
|
-
early.
|
|
4180
|
-
:param timeout:
|
|
4181
|
-
|
|
4182
|
-
|
|
4183
|
-
:param track_scores: If true
|
|
4184
|
-
scores are not used for sorting.
|
|
4734
|
+
Elasticsearch collects documents before sorting. IMPORTANT: Use with caution.
|
|
4735
|
+
Elasticsearch applies this property to each shard handling the request. When
|
|
4736
|
+
possible, let Elasticsearch perform early termination automatically. Avoid
|
|
4737
|
+
specifying this property for requests that target data streams with backing
|
|
4738
|
+
indices across multiple data tiers. If set to `0` (default), the query does
|
|
4739
|
+
not terminate early.
|
|
4740
|
+
:param timeout: The period of time to wait for a response from each shard. If
|
|
4741
|
+
no response is received before the timeout expires, the request fails and
|
|
4742
|
+
returns an error. Defaults to no timeout.
|
|
4743
|
+
:param track_scores: If `true`, calculate and return document scores, even if
|
|
4744
|
+
the scores are not used for sorting.
|
|
4185
4745
|
:param track_total_hits: Number of hits matching the query to count accurately.
|
|
4186
4746
|
If `true`, the exact number of hits is returned at the cost of some performance.
|
|
4187
4747
|
If `false`, the response does not include the total number of hits matching
|
|
4188
4748
|
the query.
|
|
4189
4749
|
:param typed_keys: If `true`, aggregation and suggester names are be prefixed
|
|
4190
4750
|
by their respective types in the response.
|
|
4191
|
-
:param version: If true
|
|
4751
|
+
:param version: If `true`, the request returns the document version as part of
|
|
4752
|
+
a hit.
|
|
4192
4753
|
"""
|
|
4193
4754
|
__path_parts: t.Dict[str, str]
|
|
4194
4755
|
if index not in SKIP_IN_PATH:
|
|
@@ -4246,8 +4807,6 @@ class AsyncElasticsearch(BaseClient):
|
|
|
4246
4807
|
__query["lenient"] = lenient
|
|
4247
4808
|
if max_concurrent_shard_requests is not None:
|
|
4248
4809
|
__query["max_concurrent_shard_requests"] = max_concurrent_shard_requests
|
|
4249
|
-
if min_compatible_shard_node is not None:
|
|
4250
|
-
__query["min_compatible_shard_node"] = min_compatible_shard_node
|
|
4251
4810
|
if pre_filter_shard_size is not None:
|
|
4252
4811
|
__query["pre_filter_shard_size"] = pre_filter_shard_size
|
|
4253
4812
|
if preference is not None:
|
|
@@ -4420,52 +4979,376 @@ class AsyncElasticsearch(BaseClient):
|
|
|
4420
4979
|
body: t.Optional[t.Dict[str, t.Any]] = None,
|
|
4421
4980
|
) -> BinaryApiResponse:
|
|
4422
4981
|
"""
|
|
4423
|
-
|
|
4424
|
-
|
|
4425
|
-
|
|
4982
|
+
.. raw:: html
|
|
4983
|
+
|
|
4984
|
+
<p>Search a vector tile.</p>
|
|
4985
|
+
<p>Search a vector tile for geospatial values.
|
|
4986
|
+
Before using this API, you should be familiar with the Mapbox vector tile specification.
|
|
4987
|
+
The API returns results as a binary mapbox vector tile.</p>
|
|
4988
|
+
<p>Internally, Elasticsearch translates a vector tile search API request into a search containing:</p>
|
|
4989
|
+
<ul>
|
|
4990
|
+
<li>A <code>geo_bounding_box</code> query on the <code><field></code>. The query uses the <code><zoom>/<x>/<y></code> tile as a bounding box.</li>
|
|
4991
|
+
<li>A <code>geotile_grid</code> or <code>geohex_grid</code> aggregation on the <code><field></code>. The <code>grid_agg</code> parameter determines the aggregation type. The aggregation uses the <code><zoom>/<x>/<y></code> tile as a bounding box.</li>
|
|
4992
|
+
<li>Optionally, a <code>geo_bounds</code> aggregation on the <code><field></code>. The search only includes this aggregation if the <code>exact_bounds</code> parameter is <code>true</code>.</li>
|
|
4993
|
+
<li>If the optional parameter <code>with_labels</code> is <code>true</code>, the internal search will include a dynamic runtime field that calls the <code>getLabelPosition</code> function of the geometry doc value. This enables the generation of new point features containing suggested geometry labels, so that, for example, multi-polygons will have only one label.</li>
|
|
4994
|
+
</ul>
|
|
4995
|
+
<p>For example, Elasticsearch may translate a vector tile search API request with a <code>grid_agg</code> argument of <code>geotile</code> and an <code>exact_bounds</code> argument of <code>true</code> into the following search</p>
|
|
4996
|
+
<pre><code>GET my-index/_search
|
|
4997
|
+
{
|
|
4998
|
+
"size": 10000,
|
|
4999
|
+
"query": {
|
|
5000
|
+
"geo_bounding_box": {
|
|
5001
|
+
"my-geo-field": {
|
|
5002
|
+
"top_left": {
|
|
5003
|
+
"lat": -40.979898069620134,
|
|
5004
|
+
"lon": -45
|
|
5005
|
+
},
|
|
5006
|
+
"bottom_right": {
|
|
5007
|
+
"lat": -66.51326044311186,
|
|
5008
|
+
"lon": 0
|
|
5009
|
+
}
|
|
5010
|
+
}
|
|
5011
|
+
}
|
|
5012
|
+
},
|
|
5013
|
+
"aggregations": {
|
|
5014
|
+
"grid": {
|
|
5015
|
+
"geotile_grid": {
|
|
5016
|
+
"field": "my-geo-field",
|
|
5017
|
+
"precision": 11,
|
|
5018
|
+
"size": 65536,
|
|
5019
|
+
"bounds": {
|
|
5020
|
+
"top_left": {
|
|
5021
|
+
"lat": -40.979898069620134,
|
|
5022
|
+
"lon": -45
|
|
5023
|
+
},
|
|
5024
|
+
"bottom_right": {
|
|
5025
|
+
"lat": -66.51326044311186,
|
|
5026
|
+
"lon": 0
|
|
5027
|
+
}
|
|
5028
|
+
}
|
|
5029
|
+
}
|
|
5030
|
+
},
|
|
5031
|
+
"bounds": {
|
|
5032
|
+
"geo_bounds": {
|
|
5033
|
+
"field": "my-geo-field",
|
|
5034
|
+
"wrap_longitude": false
|
|
5035
|
+
}
|
|
5036
|
+
}
|
|
5037
|
+
}
|
|
5038
|
+
}
|
|
5039
|
+
</code></pre>
|
|
5040
|
+
<p>The API returns results as a binary Mapbox vector tile.
|
|
5041
|
+
Mapbox vector tiles are encoded as Google Protobufs (PBF). By default, the tile contains three layers:</p>
|
|
5042
|
+
<ul>
|
|
5043
|
+
<li>A <code>hits</code> layer containing a feature for each <code><field></code> value matching the <code>geo_bounding_box</code> query.</li>
|
|
5044
|
+
<li>An <code>aggs</code> layer containing a feature for each cell of the <code>geotile_grid</code> or <code>geohex_grid</code>. The layer only contains features for cells with matching data.</li>
|
|
5045
|
+
<li>A meta layer containing:
|
|
5046
|
+
<ul>
|
|
5047
|
+
<li>A feature containing a bounding box. By default, this is the bounding box of the tile.</li>
|
|
5048
|
+
<li>Value ranges for any sub-aggregations on the <code>geotile_grid</code> or <code>geohex_grid</code>.</li>
|
|
5049
|
+
<li>Metadata for the search.</li>
|
|
5050
|
+
</ul>
|
|
5051
|
+
</li>
|
|
5052
|
+
</ul>
|
|
5053
|
+
<p>The API only returns features that can display at its zoom level.
|
|
5054
|
+
For example, if a polygon feature has no area at its zoom level, the API omits it.
|
|
5055
|
+
The API returns errors as UTF-8 encoded JSON.</p>
|
|
5056
|
+
<p>IMPORTANT: You can specify several options for this API as either a query parameter or request body parameter.
|
|
5057
|
+
If you specify both parameters, the query parameter takes precedence.</p>
|
|
5058
|
+
<p><strong>Grid precision for geotile</strong></p>
|
|
5059
|
+
<p>For a <code>grid_agg</code> of <code>geotile</code>, you can use cells in the <code>aggs</code> layer as tiles for lower zoom levels.
|
|
5060
|
+
<code>grid_precision</code> represents the additional zoom levels available through these cells. The final precision is computed by as follows: <code><zoom> + grid_precision</code>.
|
|
5061
|
+
For example, if <code><zoom></code> is 7 and <code>grid_precision</code> is 8, then the <code>geotile_grid</code> aggregation will use a precision of 15.
|
|
5062
|
+
The maximum final precision is 29.
|
|
5063
|
+
The <code>grid_precision</code> also determines the number of cells for the grid as follows: <code>(2^grid_precision) x (2^grid_precision)</code>.
|
|
5064
|
+
For example, a value of 8 divides the tile into a grid of 256 x 256 cells.
|
|
5065
|
+
The <code>aggs</code> layer only contains features for cells with matching data.</p>
|
|
5066
|
+
<p><strong>Grid precision for geohex</strong></p>
|
|
5067
|
+
<p>For a <code>grid_agg</code> of <code>geohex</code>, Elasticsearch uses <code><zoom></code> and <code>grid_precision</code> to calculate a final precision as follows: <code><zoom> + grid_precision</code>.</p>
|
|
5068
|
+
<p>This precision determines the H3 resolution of the hexagonal cells produced by the <code>geohex</code> aggregation.
|
|
5069
|
+
The following table maps the H3 resolution for each precision.
|
|
5070
|
+
For example, if <code><zoom></code> is 3 and <code>grid_precision</code> is 3, the precision is 6.
|
|
5071
|
+
At a precision of 6, hexagonal cells have an H3 resolution of 2.
|
|
5072
|
+
If <code><zoom></code> is 3 and <code>grid_precision</code> is 4, the precision is 7.
|
|
5073
|
+
At a precision of 7, hexagonal cells have an H3 resolution of 3.</p>
|
|
5074
|
+
<table>
|
|
5075
|
+
<thead>
|
|
5076
|
+
<tr>
|
|
5077
|
+
<th>Precision</th>
|
|
5078
|
+
<th>Unique tile bins</th>
|
|
5079
|
+
<th>H3 resolution</th>
|
|
5080
|
+
<th>Unique hex bins</th>
|
|
5081
|
+
<th>Ratio</th>
|
|
5082
|
+
</tr>
|
|
5083
|
+
</thead>
|
|
5084
|
+
<tbody>
|
|
5085
|
+
<tr>
|
|
5086
|
+
<td>1</td>
|
|
5087
|
+
<td>4</td>
|
|
5088
|
+
<td>0</td>
|
|
5089
|
+
<td>122</td>
|
|
5090
|
+
<td>30.5</td>
|
|
5091
|
+
</tr>
|
|
5092
|
+
<tr>
|
|
5093
|
+
<td>2</td>
|
|
5094
|
+
<td>16</td>
|
|
5095
|
+
<td>0</td>
|
|
5096
|
+
<td>122</td>
|
|
5097
|
+
<td>7.625</td>
|
|
5098
|
+
</tr>
|
|
5099
|
+
<tr>
|
|
5100
|
+
<td>3</td>
|
|
5101
|
+
<td>64</td>
|
|
5102
|
+
<td>1</td>
|
|
5103
|
+
<td>842</td>
|
|
5104
|
+
<td>13.15625</td>
|
|
5105
|
+
</tr>
|
|
5106
|
+
<tr>
|
|
5107
|
+
<td>4</td>
|
|
5108
|
+
<td>256</td>
|
|
5109
|
+
<td>1</td>
|
|
5110
|
+
<td>842</td>
|
|
5111
|
+
<td>3.2890625</td>
|
|
5112
|
+
</tr>
|
|
5113
|
+
<tr>
|
|
5114
|
+
<td>5</td>
|
|
5115
|
+
<td>1024</td>
|
|
5116
|
+
<td>2</td>
|
|
5117
|
+
<td>5882</td>
|
|
5118
|
+
<td>5.744140625</td>
|
|
5119
|
+
</tr>
|
|
5120
|
+
<tr>
|
|
5121
|
+
<td>6</td>
|
|
5122
|
+
<td>4096</td>
|
|
5123
|
+
<td>2</td>
|
|
5124
|
+
<td>5882</td>
|
|
5125
|
+
<td>1.436035156</td>
|
|
5126
|
+
</tr>
|
|
5127
|
+
<tr>
|
|
5128
|
+
<td>7</td>
|
|
5129
|
+
<td>16384</td>
|
|
5130
|
+
<td>3</td>
|
|
5131
|
+
<td>41162</td>
|
|
5132
|
+
<td>2.512329102</td>
|
|
5133
|
+
</tr>
|
|
5134
|
+
<tr>
|
|
5135
|
+
<td>8</td>
|
|
5136
|
+
<td>65536</td>
|
|
5137
|
+
<td>3</td>
|
|
5138
|
+
<td>41162</td>
|
|
5139
|
+
<td>0.6280822754</td>
|
|
5140
|
+
</tr>
|
|
5141
|
+
<tr>
|
|
5142
|
+
<td>9</td>
|
|
5143
|
+
<td>262144</td>
|
|
5144
|
+
<td>4</td>
|
|
5145
|
+
<td>288122</td>
|
|
5146
|
+
<td>1.099098206</td>
|
|
5147
|
+
</tr>
|
|
5148
|
+
<tr>
|
|
5149
|
+
<td>10</td>
|
|
5150
|
+
<td>1048576</td>
|
|
5151
|
+
<td>4</td>
|
|
5152
|
+
<td>288122</td>
|
|
5153
|
+
<td>0.2747745514</td>
|
|
5154
|
+
</tr>
|
|
5155
|
+
<tr>
|
|
5156
|
+
<td>11</td>
|
|
5157
|
+
<td>4194304</td>
|
|
5158
|
+
<td>5</td>
|
|
5159
|
+
<td>2016842</td>
|
|
5160
|
+
<td>0.4808526039</td>
|
|
5161
|
+
</tr>
|
|
5162
|
+
<tr>
|
|
5163
|
+
<td>12</td>
|
|
5164
|
+
<td>16777216</td>
|
|
5165
|
+
<td>6</td>
|
|
5166
|
+
<td>14117882</td>
|
|
5167
|
+
<td>0.8414913416</td>
|
|
5168
|
+
</tr>
|
|
5169
|
+
<tr>
|
|
5170
|
+
<td>13</td>
|
|
5171
|
+
<td>67108864</td>
|
|
5172
|
+
<td>6</td>
|
|
5173
|
+
<td>14117882</td>
|
|
5174
|
+
<td>0.2103728354</td>
|
|
5175
|
+
</tr>
|
|
5176
|
+
<tr>
|
|
5177
|
+
<td>14</td>
|
|
5178
|
+
<td>268435456</td>
|
|
5179
|
+
<td>7</td>
|
|
5180
|
+
<td>98825162</td>
|
|
5181
|
+
<td>0.3681524172</td>
|
|
5182
|
+
</tr>
|
|
5183
|
+
<tr>
|
|
5184
|
+
<td>15</td>
|
|
5185
|
+
<td>1073741824</td>
|
|
5186
|
+
<td>8</td>
|
|
5187
|
+
<td>691776122</td>
|
|
5188
|
+
<td>0.644266719</td>
|
|
5189
|
+
</tr>
|
|
5190
|
+
<tr>
|
|
5191
|
+
<td>16</td>
|
|
5192
|
+
<td>4294967296</td>
|
|
5193
|
+
<td>8</td>
|
|
5194
|
+
<td>691776122</td>
|
|
5195
|
+
<td>0.1610666797</td>
|
|
5196
|
+
</tr>
|
|
5197
|
+
<tr>
|
|
5198
|
+
<td>17</td>
|
|
5199
|
+
<td>17179869184</td>
|
|
5200
|
+
<td>9</td>
|
|
5201
|
+
<td>4842432842</td>
|
|
5202
|
+
<td>0.2818666889</td>
|
|
5203
|
+
</tr>
|
|
5204
|
+
<tr>
|
|
5205
|
+
<td>18</td>
|
|
5206
|
+
<td>68719476736</td>
|
|
5207
|
+
<td>10</td>
|
|
5208
|
+
<td>33897029882</td>
|
|
5209
|
+
<td>0.4932667053</td>
|
|
5210
|
+
</tr>
|
|
5211
|
+
<tr>
|
|
5212
|
+
<td>19</td>
|
|
5213
|
+
<td>274877906944</td>
|
|
5214
|
+
<td>11</td>
|
|
5215
|
+
<td>237279209162</td>
|
|
5216
|
+
<td>0.8632167343</td>
|
|
5217
|
+
</tr>
|
|
5218
|
+
<tr>
|
|
5219
|
+
<td>20</td>
|
|
5220
|
+
<td>1099511627776</td>
|
|
5221
|
+
<td>11</td>
|
|
5222
|
+
<td>237279209162</td>
|
|
5223
|
+
<td>0.2158041836</td>
|
|
5224
|
+
</tr>
|
|
5225
|
+
<tr>
|
|
5226
|
+
<td>21</td>
|
|
5227
|
+
<td>4398046511104</td>
|
|
5228
|
+
<td>12</td>
|
|
5229
|
+
<td>1660954464122</td>
|
|
5230
|
+
<td>0.3776573213</td>
|
|
5231
|
+
</tr>
|
|
5232
|
+
<tr>
|
|
5233
|
+
<td>22</td>
|
|
5234
|
+
<td>17592186044416</td>
|
|
5235
|
+
<td>13</td>
|
|
5236
|
+
<td>11626681248842</td>
|
|
5237
|
+
<td>0.6609003122</td>
|
|
5238
|
+
</tr>
|
|
5239
|
+
<tr>
|
|
5240
|
+
<td>23</td>
|
|
5241
|
+
<td>70368744177664</td>
|
|
5242
|
+
<td>13</td>
|
|
5243
|
+
<td>11626681248842</td>
|
|
5244
|
+
<td>0.165225078</td>
|
|
5245
|
+
</tr>
|
|
5246
|
+
<tr>
|
|
5247
|
+
<td>24</td>
|
|
5248
|
+
<td>281474976710656</td>
|
|
5249
|
+
<td>14</td>
|
|
5250
|
+
<td>81386768741882</td>
|
|
5251
|
+
<td>0.2891438866</td>
|
|
5252
|
+
</tr>
|
|
5253
|
+
<tr>
|
|
5254
|
+
<td>25</td>
|
|
5255
|
+
<td>1125899906842620</td>
|
|
5256
|
+
<td>15</td>
|
|
5257
|
+
<td>569707381193162</td>
|
|
5258
|
+
<td>0.5060018015</td>
|
|
5259
|
+
</tr>
|
|
5260
|
+
<tr>
|
|
5261
|
+
<td>26</td>
|
|
5262
|
+
<td>4503599627370500</td>
|
|
5263
|
+
<td>15</td>
|
|
5264
|
+
<td>569707381193162</td>
|
|
5265
|
+
<td>0.1265004504</td>
|
|
5266
|
+
</tr>
|
|
5267
|
+
<tr>
|
|
5268
|
+
<td>27</td>
|
|
5269
|
+
<td>18014398509482000</td>
|
|
5270
|
+
<td>15</td>
|
|
5271
|
+
<td>569707381193162</td>
|
|
5272
|
+
<td>0.03162511259</td>
|
|
5273
|
+
</tr>
|
|
5274
|
+
<tr>
|
|
5275
|
+
<td>28</td>
|
|
5276
|
+
<td>72057594037927900</td>
|
|
5277
|
+
<td>15</td>
|
|
5278
|
+
<td>569707381193162</td>
|
|
5279
|
+
<td>0.007906278149</td>
|
|
5280
|
+
</tr>
|
|
5281
|
+
<tr>
|
|
5282
|
+
<td>29</td>
|
|
5283
|
+
<td>288230376151712000</td>
|
|
5284
|
+
<td>15</td>
|
|
5285
|
+
<td>569707381193162</td>
|
|
5286
|
+
<td>0.001976569537</td>
|
|
5287
|
+
</tr>
|
|
5288
|
+
</tbody>
|
|
5289
|
+
</table>
|
|
5290
|
+
<p>Hexagonal cells don't align perfectly on a vector tile.
|
|
5291
|
+
Some cells may intersect more than one vector tile.
|
|
5292
|
+
To compute the H3 resolution for each precision, Elasticsearch compares the average density of hexagonal bins at each resolution with the average density of tile bins at each zoom level.
|
|
5293
|
+
Elasticsearch uses the H3 resolution that is closest to the corresponding geotile density.</p>
|
|
5294
|
+
|
|
5295
|
+
|
|
5296
|
+
`<https://www.elastic.co/docs/api/doc/elasticsearch/v9/operation/operation-search-mvt>`_
|
|
4426
5297
|
|
|
4427
5298
|
:param index: Comma-separated list of data streams, indices, or aliases to search
|
|
4428
5299
|
:param field: Field containing geospatial data to return
|
|
4429
5300
|
:param zoom: Zoom level for the vector tile to search
|
|
4430
5301
|
:param x: X coordinate for the vector tile to search
|
|
4431
5302
|
:param y: Y coordinate for the vector tile to search
|
|
4432
|
-
:param aggs: Sub-aggregations for the geotile_grid.
|
|
4433
|
-
types: - avg -
|
|
4434
|
-
|
|
4435
|
-
|
|
4436
|
-
|
|
4437
|
-
:param
|
|
4438
|
-
|
|
4439
|
-
|
|
4440
|
-
|
|
4441
|
-
|
|
4442
|
-
|
|
5303
|
+
:param aggs: Sub-aggregations for the geotile_grid. It supports the following
|
|
5304
|
+
aggregation types: - `avg` - `boxplot` - `cardinality` - `extended stats`
|
|
5305
|
+
- `max` - `median absolute deviation` - `min` - `percentile` - `percentile-rank`
|
|
5306
|
+
- `stats` - `sum` - `value count` The aggregation names can't start with
|
|
5307
|
+
`_mvt_`. The `_mvt_` prefix is reserved for internal aggregations.
|
|
5308
|
+
:param buffer: The size, in pixels, of a clipping buffer outside the tile. This
|
|
5309
|
+
allows renderers to avoid outline artifacts from geometries that extend past
|
|
5310
|
+
the extent of the tile.
|
|
5311
|
+
:param exact_bounds: If `false`, the meta layer's feature is the bounding box
|
|
5312
|
+
of the tile. If `true`, the meta layer's feature is a bounding box resulting
|
|
5313
|
+
from a `geo_bounds` aggregation. The aggregation runs on <field> values that
|
|
5314
|
+
intersect the `<zoom>/<x>/<y>` tile with `wrap_longitude` set to `false`.
|
|
5315
|
+
The resulting bounding box may be larger than the vector tile.
|
|
5316
|
+
:param extent: The size, in pixels, of a side of the tile. Vector tiles are square
|
|
4443
5317
|
with equal sides.
|
|
4444
|
-
:param fields:
|
|
4445
|
-
This parameter does not support fields with array values. Fields with
|
|
4446
|
-
values may return inconsistent results.
|
|
4447
|
-
:param grid_agg:
|
|
5318
|
+
:param fields: The fields to return in the `hits` layer. It supports wildcards
|
|
5319
|
+
(`*`). This parameter does not support fields with array values. Fields with
|
|
5320
|
+
array values may return inconsistent results.
|
|
5321
|
+
:param grid_agg: The aggregation used to create a grid for the `field`.
|
|
4448
5322
|
:param grid_precision: Additional zoom levels available through the aggs layer.
|
|
4449
|
-
For example, if
|
|
4450
|
-
level 15. Accepts 0-8. If 0, results don
|
|
5323
|
+
For example, if `<zoom>` is `7` and `grid_precision` is `8`, you can zoom
|
|
5324
|
+
in up to level 15. Accepts 0-8. If 0, results don't include the aggs layer.
|
|
4451
5325
|
:param grid_type: Determines the geometry type for features in the aggs layer.
|
|
4452
|
-
In the aggs layer, each feature represents a geotile_grid cell. If
|
|
4453
|
-
each feature is a
|
|
5326
|
+
In the aggs layer, each feature represents a `geotile_grid` cell. If `grid,
|
|
5327
|
+
each feature is a polygon of the cells bounding box. If `point`, each feature
|
|
4454
5328
|
is a Point that is the centroid of the cell.
|
|
4455
|
-
:param query:
|
|
5329
|
+
:param query: The query DSL used to filter documents for the search.
|
|
4456
5330
|
:param runtime_mappings: Defines one or more runtime fields in the search request.
|
|
4457
5331
|
These fields take precedence over mapped fields with the same name.
|
|
4458
|
-
:param size:
|
|
4459
|
-
0-10000. If 0, results don
|
|
4460
|
-
:param sort:
|
|
4461
|
-
a bounding box for each feature. It sorts features based on this box
|
|
5332
|
+
:param size: The maximum number of features to return in the hits layer. Accepts
|
|
5333
|
+
0-10000. If 0, results don't include the hits layer.
|
|
5334
|
+
:param sort: Sort the features in the hits layer. By default, the API calculates
|
|
5335
|
+
a bounding box for each feature. It sorts features based on this box's diagonal
|
|
4462
5336
|
length, from longest to shortest.
|
|
4463
|
-
:param track_total_hits:
|
|
5337
|
+
:param track_total_hits: The number of hits matching the query to count accurately.
|
|
4464
5338
|
If `true`, the exact number of hits is returned at the cost of some performance.
|
|
4465
5339
|
If `false`, the response does not include the total number of hits matching
|
|
4466
5340
|
the query.
|
|
4467
5341
|
:param with_labels: If `true`, the hits and aggs layers will contain additional
|
|
4468
5342
|
point features representing suggested label positions for the original features.
|
|
5343
|
+
* `Point` and `MultiPoint` features will have one of the points selected.
|
|
5344
|
+
* `Polygon` and `MultiPolygon` features will have a single point generated,
|
|
5345
|
+
either the centroid, if it is within the polygon, or another point within
|
|
5346
|
+
the polygon selected from the sorted triangle-tree. * `LineString` features
|
|
5347
|
+
will likewise provide a roughly central point selected from the triangle-tree.
|
|
5348
|
+
* The aggregation results will provide one central point for each aggregation
|
|
5349
|
+
bucket. All attributes from the original features will also be copied to
|
|
5350
|
+
the new label features. In addition, the new features will be distinguishable
|
|
5351
|
+
using the tag `_mvt_label_position`.
|
|
4469
5352
|
"""
|
|
4470
5353
|
if index in SKIP_IN_PATH:
|
|
4471
5354
|
raise ValueError("Empty value passed for parameter 'index'")
|
|
@@ -4569,20 +5452,26 @@ class AsyncElasticsearch(BaseClient):
|
|
|
4569
5452
|
human: t.Optional[bool] = None,
|
|
4570
5453
|
ignore_unavailable: t.Optional[bool] = None,
|
|
4571
5454
|
local: t.Optional[bool] = None,
|
|
5455
|
+
master_timeout: t.Optional[t.Union[str, t.Literal[-1], t.Literal[0]]] = None,
|
|
4572
5456
|
preference: t.Optional[str] = None,
|
|
4573
5457
|
pretty: t.Optional[bool] = None,
|
|
4574
5458
|
routing: t.Optional[str] = None,
|
|
4575
5459
|
) -> ObjectApiResponse[t.Any]:
|
|
4576
5460
|
"""
|
|
4577
|
-
|
|
4578
|
-
|
|
4579
|
-
|
|
4580
|
-
|
|
5461
|
+
.. raw:: html
|
|
5462
|
+
|
|
5463
|
+
<p>Get the search shards.</p>
|
|
5464
|
+
<p>Get the indices and shards that a search request would be run against.
|
|
5465
|
+
This information can be useful for working out issues or planning optimizations with routing and shard preferences.
|
|
5466
|
+
When filtered aliases are used, the filter is returned as part of the <code>indices</code> section.</p>
|
|
5467
|
+
<p>If the Elasticsearch security features are enabled, you must have the <code>view_index_metadata</code> or <code>manage</code> index privilege for the target data stream, index, or alias.</p>
|
|
4581
5468
|
|
|
4582
|
-
`<https://www.elastic.co/guide/en/elasticsearch/reference/8.17/search-shards.html>`_
|
|
4583
5469
|
|
|
4584
|
-
|
|
4585
|
-
|
|
5470
|
+
`<https://www.elastic.co/docs/api/doc/elasticsearch/v9/operation/operation-search-shards>`_
|
|
5471
|
+
|
|
5472
|
+
:param index: A comma-separated list of data streams, indices, and aliases to
|
|
5473
|
+
search. It supports wildcards (`*`). To search all data streams and indices,
|
|
5474
|
+
omit this parameter or use `*` or `_all`.
|
|
4586
5475
|
:param allow_no_indices: If `false`, the request returns an error if any wildcard
|
|
4587
5476
|
expression, index alias, or `_all` value targets only missing or closed indices.
|
|
4588
5477
|
This behavior applies even if the request targets other open indices. For
|
|
@@ -4596,9 +5485,13 @@ class AsyncElasticsearch(BaseClient):
|
|
|
4596
5485
|
a missing or closed index.
|
|
4597
5486
|
:param local: If `true`, the request retrieves information from the local node
|
|
4598
5487
|
only.
|
|
4599
|
-
:param
|
|
4600
|
-
|
|
4601
|
-
|
|
5488
|
+
:param master_timeout: The period to wait for a connection to the master node.
|
|
5489
|
+
If the master node is not available before the timeout expires, the request
|
|
5490
|
+
fails and returns an error. IT can also be set to `-1` to indicate that the
|
|
5491
|
+
request should never timeout.
|
|
5492
|
+
:param preference: The node or shard the operation should be performed on. It
|
|
5493
|
+
is random by default.
|
|
5494
|
+
:param routing: A custom value used to route operations to a specific shard.
|
|
4602
5495
|
"""
|
|
4603
5496
|
__path_parts: t.Dict[str, str]
|
|
4604
5497
|
if index not in SKIP_IN_PATH:
|
|
@@ -4622,6 +5515,8 @@ class AsyncElasticsearch(BaseClient):
|
|
|
4622
5515
|
__query["ignore_unavailable"] = ignore_unavailable
|
|
4623
5516
|
if local is not None:
|
|
4624
5517
|
__query["local"] = local
|
|
5518
|
+
if master_timeout is not None:
|
|
5519
|
+
__query["master_timeout"] = master_timeout
|
|
4625
5520
|
if preference is not None:
|
|
4626
5521
|
__query["preference"] = preference
|
|
4627
5522
|
if pretty is not None:
|
|
@@ -4673,17 +5568,20 @@ class AsyncElasticsearch(BaseClient):
|
|
|
4673
5568
|
search_type: t.Optional[
|
|
4674
5569
|
t.Union[str, t.Literal["dfs_query_then_fetch", "query_then_fetch"]]
|
|
4675
5570
|
] = None,
|
|
4676
|
-
source: t.Optional[str] = None,
|
|
5571
|
+
source: t.Optional[t.Union[str, t.Mapping[str, t.Any]]] = None,
|
|
4677
5572
|
typed_keys: t.Optional[bool] = None,
|
|
4678
5573
|
body: t.Optional[t.Dict[str, t.Any]] = None,
|
|
4679
5574
|
) -> ObjectApiResponse[t.Any]:
|
|
4680
5575
|
"""
|
|
4681
|
-
|
|
5576
|
+
.. raw:: html
|
|
5577
|
+
|
|
5578
|
+
<p>Run a search with a search template.</p>
|
|
5579
|
+
|
|
4682
5580
|
|
|
4683
|
-
`<https://www.elastic.co/
|
|
5581
|
+
`<https://www.elastic.co/docs/api/doc/elasticsearch/v9/operation/operation-search-template>`_
|
|
4684
5582
|
|
|
4685
|
-
:param index:
|
|
4686
|
-
|
|
5583
|
+
:param index: A comma-separated list of data streams, indices, and aliases to
|
|
5584
|
+
search. It supports wildcards (`*`).
|
|
4687
5585
|
:param allow_no_indices: If `false`, the request returns an error if any wildcard
|
|
4688
5586
|
expression, index alias, or `_all` value targets only missing or closed indices.
|
|
4689
5587
|
This behavior applies even if the request targets other open indices. For
|
|
@@ -4691,32 +5589,34 @@ class AsyncElasticsearch(BaseClient):
|
|
|
4691
5589
|
with `foo` but no index starts with `bar`.
|
|
4692
5590
|
:param ccs_minimize_roundtrips: If `true`, network round-trips are minimized
|
|
4693
5591
|
for cross-cluster search requests.
|
|
4694
|
-
:param expand_wildcards:
|
|
4695
|
-
request can target data streams, this argument determines whether
|
|
4696
|
-
expressions match hidden data streams. Supports comma-separated
|
|
4697
|
-
as `open,hidden`. Valid values are: `all`, `open`, `closed`,
|
|
5592
|
+
:param expand_wildcards: The type of index that wildcard patterns can match.
|
|
5593
|
+
If the request can target data streams, this argument determines whether
|
|
5594
|
+
wildcard expressions match hidden data streams. Supports comma-separated
|
|
5595
|
+
values, such as `open,hidden`. Valid values are: `all`, `open`, `closed`,
|
|
5596
|
+
`hidden`, `none`.
|
|
4698
5597
|
:param explain: If `true`, returns detailed information about score calculation
|
|
4699
|
-
as part of each hit.
|
|
4700
|
-
|
|
4701
|
-
|
|
5598
|
+
as part of each hit. If you specify both this and the `explain` query parameter,
|
|
5599
|
+
the API uses only the query parameter.
|
|
5600
|
+
:param id: The ID of the search template to use. If no `source` is specified,
|
|
5601
|
+
this parameter is required.
|
|
4702
5602
|
:param ignore_throttled: If `true`, specified concrete, expanded, or aliased
|
|
4703
5603
|
indices are not included in the response when throttled.
|
|
4704
5604
|
:param ignore_unavailable: If `false`, the request returns an error if it targets
|
|
4705
5605
|
a missing or closed index.
|
|
4706
5606
|
:param params: Key-value pairs used to replace Mustache variables in the template.
|
|
4707
5607
|
The key is the variable name. The value is the variable value.
|
|
4708
|
-
:param preference:
|
|
4709
|
-
|
|
5608
|
+
:param preference: The node or shard the operation should be performed on. It
|
|
5609
|
+
is random by default.
|
|
4710
5610
|
:param profile: If `true`, the query execution is profiled.
|
|
4711
|
-
:param rest_total_hits_as_int: If true
|
|
4712
|
-
in the response.
|
|
4713
|
-
:param routing:
|
|
5611
|
+
:param rest_total_hits_as_int: If `true`, `hits.total` is rendered as an integer
|
|
5612
|
+
in the response. If `false`, it is rendered as an object.
|
|
5613
|
+
:param routing: A custom value used to route operations to a specific shard.
|
|
4714
5614
|
:param scroll: Specifies how long a consistent view of the index should be maintained
|
|
4715
5615
|
for scrolled search.
|
|
4716
5616
|
:param search_type: The type of the search operation.
|
|
4717
5617
|
:param source: An inline search template. Supports the same parameters as the
|
|
4718
|
-
search API's request body.
|
|
4719
|
-
specified, this parameter is required.
|
|
5618
|
+
search API's request body. It also supports Mustache variables. If no `id`
|
|
5619
|
+
is specified, this parameter is required.
|
|
4720
5620
|
:param typed_keys: If `true`, the response prefixes aggregation and suggester
|
|
4721
5621
|
names with their respective types.
|
|
4722
5622
|
"""
|
|
@@ -4810,34 +5710,39 @@ class AsyncElasticsearch(BaseClient):
|
|
|
4810
5710
|
body: t.Optional[t.Dict[str, t.Any]] = None,
|
|
4811
5711
|
) -> ObjectApiResponse[t.Any]:
|
|
4812
5712
|
"""
|
|
4813
|
-
|
|
4814
|
-
This "terms enum" API is designed for low-latency look-ups used in auto-complete
|
|
4815
|
-
scenarios. If the `complete` property in the response is false, the returned
|
|
4816
|
-
terms set may be incomplete and should be treated as approximate. This can occur
|
|
4817
|
-
due to a few reasons, such as a request timeout or a node error. NOTE: The terms
|
|
4818
|
-
enum API may return terms from deleted documents. Deleted documents are initially
|
|
4819
|
-
only marked as deleted. It is not until their segments are merged that documents
|
|
4820
|
-
are actually deleted. Until that happens, the terms enum API will return terms
|
|
4821
|
-
from these documents.
|
|
4822
|
-
|
|
4823
|
-
`<https://www.elastic.co/guide/en/elasticsearch/reference/8.17/search-terms-enum.html>`_
|
|
5713
|
+
.. raw:: html
|
|
4824
5714
|
|
|
4825
|
-
|
|
4826
|
-
|
|
5715
|
+
<p>Get terms in an index.</p>
|
|
5716
|
+
<p>Discover terms that match a partial string in an index.
|
|
5717
|
+
This API is designed for low-latency look-ups used in auto-complete scenarios.</p>
|
|
5718
|
+
<blockquote>
|
|
5719
|
+
<p>info
|
|
5720
|
+
The terms enum API may return terms from deleted documents. Deleted documents are initially only marked as deleted. It is not until their segments are merged that documents are actually deleted. Until that happens, the terms enum API will return terms from these documents.</p>
|
|
5721
|
+
</blockquote>
|
|
5722
|
+
|
|
5723
|
+
|
|
5724
|
+
`<https://www.elastic.co/docs/api/doc/elasticsearch/v9/operation/operation-terms-enum>`_
|
|
5725
|
+
|
|
5726
|
+
:param index: A comma-separated list of data streams, indices, and index aliases
|
|
5727
|
+
to search. Wildcard (`*`) expressions are supported. To search all data streams
|
|
5728
|
+
or indices, omit this parameter or use `*` or `_all`.
|
|
4827
5729
|
:param field: The string to match at the start of indexed terms. If not provided,
|
|
4828
5730
|
all terms in the field are considered.
|
|
4829
|
-
:param case_insensitive: When true the provided search string is matched against
|
|
5731
|
+
:param case_insensitive: When `true`, the provided search string is matched against
|
|
4830
5732
|
index terms without case sensitivity.
|
|
4831
|
-
:param index_filter:
|
|
4832
|
-
|
|
4833
|
-
:param search_after:
|
|
4834
|
-
|
|
4835
|
-
|
|
4836
|
-
|
|
4837
|
-
|
|
4838
|
-
|
|
4839
|
-
|
|
4840
|
-
|
|
5733
|
+
:param index_filter: Filter an index shard if the provided query rewrites to
|
|
5734
|
+
`match_none`.
|
|
5735
|
+
:param search_after: The string after which terms in the index should be returned.
|
|
5736
|
+
It allows for a form of pagination if the last result from one request is
|
|
5737
|
+
passed as the `search_after` parameter for a subsequent request.
|
|
5738
|
+
:param size: The number of matching terms to return.
|
|
5739
|
+
:param string: The string to match at the start of indexed terms. If it is not
|
|
5740
|
+
provided, all terms in the field are considered. > info > The prefix string
|
|
5741
|
+
cannot be larger than the largest possible keyword value, which is Lucene's
|
|
5742
|
+
term byte-length limit of 32766.
|
|
5743
|
+
:param timeout: The maximum length of time to spend collecting results. If the
|
|
5744
|
+
timeout is exceeded the `complete` flag set to `false` in the response and
|
|
5745
|
+
the results may be partial or empty.
|
|
4841
5746
|
"""
|
|
4842
5747
|
if index in SKIP_IN_PATH:
|
|
4843
5748
|
raise ValueError("Empty value passed for parameter 'index'")
|
|
@@ -4886,7 +5791,20 @@ class AsyncElasticsearch(BaseClient):
|
|
|
4886
5791
|
)
|
|
4887
5792
|
|
|
4888
5793
|
@_rewrite_parameters(
|
|
4889
|
-
body_fields=(
|
|
5794
|
+
body_fields=(
|
|
5795
|
+
"doc",
|
|
5796
|
+
"field_statistics",
|
|
5797
|
+
"fields",
|
|
5798
|
+
"filter",
|
|
5799
|
+
"offsets",
|
|
5800
|
+
"payloads",
|
|
5801
|
+
"per_field_analyzer",
|
|
5802
|
+
"positions",
|
|
5803
|
+
"routing",
|
|
5804
|
+
"term_statistics",
|
|
5805
|
+
"version",
|
|
5806
|
+
"version_type",
|
|
5807
|
+
),
|
|
4890
5808
|
)
|
|
4891
5809
|
async def termvectors(
|
|
4892
5810
|
self,
|
|
@@ -4916,33 +5834,77 @@ class AsyncElasticsearch(BaseClient):
|
|
|
4916
5834
|
body: t.Optional[t.Dict[str, t.Any]] = None,
|
|
4917
5835
|
) -> ObjectApiResponse[t.Any]:
|
|
4918
5836
|
"""
|
|
4919
|
-
|
|
4920
|
-
|
|
4921
|
-
|
|
4922
|
-
|
|
4923
|
-
|
|
4924
|
-
|
|
4925
|
-
|
|
5837
|
+
.. raw:: html
|
|
5838
|
+
|
|
5839
|
+
<p>Get term vector information.</p>
|
|
5840
|
+
<p>Get information and statistics about terms in the fields of a particular document.</p>
|
|
5841
|
+
<p>You can retrieve term vectors for documents stored in the index or for artificial documents passed in the body of the request.
|
|
5842
|
+
You can specify the fields you are interested in through the <code>fields</code> parameter or by adding the fields to the request body.
|
|
5843
|
+
For example:</p>
|
|
5844
|
+
<pre><code>GET /my-index-000001/_termvectors/1?fields=message
|
|
5845
|
+
</code></pre>
|
|
5846
|
+
<p>Fields can be specified using wildcards, similar to the multi match query.</p>
|
|
5847
|
+
<p>Term vectors are real-time by default, not near real-time.
|
|
5848
|
+
This can be changed by setting <code>realtime</code> parameter to <code>false</code>.</p>
|
|
5849
|
+
<p>You can request three types of values: <em>term information</em>, <em>term statistics</em>, and <em>field statistics</em>.
|
|
5850
|
+
By default, all term information and field statistics are returned for all fields but term statistics are excluded.</p>
|
|
5851
|
+
<p><strong>Term information</strong></p>
|
|
5852
|
+
<ul>
|
|
5853
|
+
<li>term frequency in the field (always returned)</li>
|
|
5854
|
+
<li>term positions (<code>positions: true</code>)</li>
|
|
5855
|
+
<li>start and end offsets (<code>offsets: true</code>)</li>
|
|
5856
|
+
<li>term payloads (<code>payloads: true</code>), as base64 encoded bytes</li>
|
|
5857
|
+
</ul>
|
|
5858
|
+
<p>If the requested information wasn't stored in the index, it will be computed on the fly if possible.
|
|
5859
|
+
Additionally, term vectors could be computed for documents not even existing in the index, but instead provided by the user.</p>
|
|
5860
|
+
<blockquote>
|
|
5861
|
+
<p>warn
|
|
5862
|
+
Start and end offsets assume UTF-16 encoding is being used. If you want to use these offsets in order to get the original text that produced this token, you should make sure that the string you are taking a sub-string of is also encoded using UTF-16.</p>
|
|
5863
|
+
</blockquote>
|
|
5864
|
+
<p><strong>Behaviour</strong></p>
|
|
5865
|
+
<p>The term and field statistics are not accurate.
|
|
5866
|
+
Deleted documents are not taken into account.
|
|
5867
|
+
The information is only retrieved for the shard the requested document resides in.
|
|
5868
|
+
The term and field statistics are therefore only useful as relative measures whereas the absolute numbers have no meaning in this context.
|
|
5869
|
+
By default, when requesting term vectors of artificial documents, a shard to get the statistics from is randomly selected.
|
|
5870
|
+
Use <code>routing</code> only to hit a particular shard.</p>
|
|
5871
|
+
|
|
5872
|
+
|
|
5873
|
+
`<https://www.elastic.co/docs/api/doc/elasticsearch/v9/operation/operation-termvectors>`_
|
|
5874
|
+
|
|
5875
|
+
:param index: The name of the index that contains the document.
|
|
5876
|
+
:param id: A unique identifier for the document.
|
|
4926
5877
|
:param doc: An artificial document (a document not present in the index) for
|
|
4927
5878
|
which you want to retrieve term vectors.
|
|
4928
|
-
:param field_statistics: If `true`, the response includes
|
|
4929
|
-
|
|
4930
|
-
|
|
4931
|
-
|
|
4932
|
-
|
|
4933
|
-
:param
|
|
5879
|
+
:param field_statistics: If `true`, the response includes: * The document count
|
|
5880
|
+
(how many documents contain this field). * The sum of document frequencies
|
|
5881
|
+
(the sum of document frequencies for all terms in this field). * The sum
|
|
5882
|
+
of total term frequencies (the sum of total term frequencies of each term
|
|
5883
|
+
in this field).
|
|
5884
|
+
:param fields: A list of fields to include in the statistics. It is used as the
|
|
5885
|
+
default list unless a specific field list is provided in the `completion_fields`
|
|
5886
|
+
or `fielddata_fields` parameters.
|
|
5887
|
+
:param filter: Filter terms based on their tf-idf scores. This could be useful
|
|
5888
|
+
in order find out a good characteristic vector of a document. This feature
|
|
5889
|
+
works in a similar manner to the second phase of the More Like This Query.
|
|
4934
5890
|
:param offsets: If `true`, the response includes term offsets.
|
|
4935
5891
|
:param payloads: If `true`, the response includes term payloads.
|
|
4936
|
-
:param per_field_analyzer:
|
|
5892
|
+
:param per_field_analyzer: Override the default per-field analyzer. This is useful
|
|
5893
|
+
in order to generate term vectors in any fashion, especially when using artificial
|
|
5894
|
+
documents. When providing an analyzer for a field that already stores term
|
|
5895
|
+
vectors, the term vectors will be regenerated.
|
|
4937
5896
|
:param positions: If `true`, the response includes term positions.
|
|
4938
|
-
:param preference:
|
|
4939
|
-
|
|
5897
|
+
:param preference: The node or shard the operation should be performed on. It
|
|
5898
|
+
is random by default.
|
|
4940
5899
|
:param realtime: If true, the request is real-time as opposed to near-real-time.
|
|
4941
|
-
:param routing:
|
|
4942
|
-
|
|
4943
|
-
|
|
5900
|
+
:param routing: A custom value that is used to route operations to a specific
|
|
5901
|
+
shard.
|
|
5902
|
+
:param term_statistics: If `true`, the response includes: * The total term frequency
|
|
5903
|
+
(how often a term occurs in all documents). * The document frequency (the
|
|
5904
|
+
number of documents containing the current term). By default these values
|
|
5905
|
+
are not returned since term statistics can have a serious performance impact.
|
|
4944
5906
|
:param version: If `true`, returns the document version as part of a hit.
|
|
4945
|
-
:param version_type:
|
|
5907
|
+
:param version_type: The version type.
|
|
4946
5908
|
"""
|
|
4947
5909
|
if index in SKIP_IN_PATH:
|
|
4948
5910
|
raise ValueError("Empty value passed for parameter 'index'")
|
|
@@ -4959,41 +5921,41 @@ class AsyncElasticsearch(BaseClient):
|
|
|
4959
5921
|
__body: t.Dict[str, t.Any] = body if body is not None else {}
|
|
4960
5922
|
if error_trace is not None:
|
|
4961
5923
|
__query["error_trace"] = error_trace
|
|
4962
|
-
if field_statistics is not None:
|
|
4963
|
-
__query["field_statistics"] = field_statistics
|
|
4964
|
-
if fields is not None:
|
|
4965
|
-
__query["fields"] = fields
|
|
4966
5924
|
if filter_path is not None:
|
|
4967
5925
|
__query["filter_path"] = filter_path
|
|
4968
5926
|
if human is not None:
|
|
4969
5927
|
__query["human"] = human
|
|
4970
|
-
if offsets is not None:
|
|
4971
|
-
__query["offsets"] = offsets
|
|
4972
|
-
if payloads is not None:
|
|
4973
|
-
__query["payloads"] = payloads
|
|
4974
|
-
if positions is not None:
|
|
4975
|
-
__query["positions"] = positions
|
|
4976
5928
|
if preference is not None:
|
|
4977
5929
|
__query["preference"] = preference
|
|
4978
5930
|
if pretty is not None:
|
|
4979
5931
|
__query["pretty"] = pretty
|
|
4980
5932
|
if realtime is not None:
|
|
4981
5933
|
__query["realtime"] = realtime
|
|
4982
|
-
if routing is not None:
|
|
4983
|
-
__query["routing"] = routing
|
|
4984
|
-
if term_statistics is not None:
|
|
4985
|
-
__query["term_statistics"] = term_statistics
|
|
4986
|
-
if version is not None:
|
|
4987
|
-
__query["version"] = version
|
|
4988
|
-
if version_type is not None:
|
|
4989
|
-
__query["version_type"] = version_type
|
|
4990
5934
|
if not __body:
|
|
4991
5935
|
if doc is not None:
|
|
4992
5936
|
__body["doc"] = doc
|
|
5937
|
+
if field_statistics is not None:
|
|
5938
|
+
__body["field_statistics"] = field_statistics
|
|
5939
|
+
if fields is not None:
|
|
5940
|
+
__body["fields"] = fields
|
|
4993
5941
|
if filter is not None:
|
|
4994
5942
|
__body["filter"] = filter
|
|
5943
|
+
if offsets is not None:
|
|
5944
|
+
__body["offsets"] = offsets
|
|
5945
|
+
if payloads is not None:
|
|
5946
|
+
__body["payloads"] = payloads
|
|
4995
5947
|
if per_field_analyzer is not None:
|
|
4996
5948
|
__body["per_field_analyzer"] = per_field_analyzer
|
|
5949
|
+
if positions is not None:
|
|
5950
|
+
__body["positions"] = positions
|
|
5951
|
+
if routing is not None:
|
|
5952
|
+
__body["routing"] = routing
|
|
5953
|
+
if term_statistics is not None:
|
|
5954
|
+
__body["term_statistics"] = term_statistics
|
|
5955
|
+
if version is not None:
|
|
5956
|
+
__body["version"] = version
|
|
5957
|
+
if version_type is not None:
|
|
5958
|
+
__body["version_type"] = version_type
|
|
4997
5959
|
if not __body:
|
|
4998
5960
|
__body = None # type: ignore[assignment]
|
|
4999
5961
|
__headers = {"accept": "application/json"}
|
|
@@ -5038,6 +6000,7 @@ class AsyncElasticsearch(BaseClient):
|
|
|
5038
6000
|
human: t.Optional[bool] = None,
|
|
5039
6001
|
if_primary_term: t.Optional[int] = None,
|
|
5040
6002
|
if_seq_no: t.Optional[int] = None,
|
|
6003
|
+
include_source_on_error: t.Optional[bool] = None,
|
|
5041
6004
|
lang: t.Optional[str] = None,
|
|
5042
6005
|
pretty: t.Optional[bool] = None,
|
|
5043
6006
|
refresh: t.Optional[
|
|
@@ -5059,46 +6022,67 @@ class AsyncElasticsearch(BaseClient):
|
|
|
5059
6022
|
body: t.Optional[t.Dict[str, t.Any]] = None,
|
|
5060
6023
|
) -> ObjectApiResponse[t.Any]:
|
|
5061
6024
|
"""
|
|
5062
|
-
|
|
5063
|
-
|
|
5064
|
-
|
|
5065
|
-
|
|
5066
|
-
|
|
5067
|
-
|
|
5068
|
-
|
|
5069
|
-
|
|
5070
|
-
|
|
5071
|
-
|
|
5072
|
-
|
|
5073
|
-
|
|
6025
|
+
.. raw:: html
|
|
6026
|
+
|
|
6027
|
+
<p>Update a document.</p>
|
|
6028
|
+
<p>Update a document by running a script or passing a partial document.</p>
|
|
6029
|
+
<p>If the Elasticsearch security features are enabled, you must have the <code>index</code> or <code>write</code> index privilege for the target index or index alias.</p>
|
|
6030
|
+
<p>The script can update, delete, or skip modifying the document.
|
|
6031
|
+
The API also supports passing a partial document, which is merged into the existing document.
|
|
6032
|
+
To fully replace an existing document, use the index API.
|
|
6033
|
+
This operation:</p>
|
|
6034
|
+
<ul>
|
|
6035
|
+
<li>Gets the document (collocated with the shard) from the index.</li>
|
|
6036
|
+
<li>Runs the specified script.</li>
|
|
6037
|
+
<li>Indexes the result.</li>
|
|
6038
|
+
</ul>
|
|
6039
|
+
<p>The document must still be reindexed, but using this API removes some network roundtrips and reduces chances of version conflicts between the GET and the index operation.</p>
|
|
6040
|
+
<p>The <code>_source</code> field must be enabled to use this API.
|
|
6041
|
+
In addition to <code>_source</code>, you can access the following variables through the <code>ctx</code> map: <code>_index</code>, <code>_type</code>, <code>_id</code>, <code>_version</code>, <code>_routing</code>, and <code>_now</code> (the current timestamp).</p>
|
|
6042
|
+
|
|
6043
|
+
|
|
6044
|
+
`<https://www.elastic.co/docs/api/doc/elasticsearch/v9/operation/operation-update>`_
|
|
6045
|
+
|
|
6046
|
+
:param index: The name of the target index. By default, the index is created
|
|
6047
|
+
automatically if it doesn't exist.
|
|
6048
|
+
:param id: A unique identifier for the document to be updated.
|
|
6049
|
+
:param detect_noop: If `true`, the `result` in the response is set to `noop`
|
|
6050
|
+
(no operation) when there are no changes to the document.
|
|
6051
|
+
:param doc: A partial update to an existing document. If both `doc` and `script`
|
|
6052
|
+
are specified, `doc` is ignored.
|
|
6053
|
+
:param doc_as_upsert: If `true`, use the contents of 'doc' as the value of 'upsert'.
|
|
6054
|
+
NOTE: Using ingest pipelines with `doc_as_upsert` is not supported.
|
|
5074
6055
|
:param if_primary_term: Only perform the operation if the document has this primary
|
|
5075
6056
|
term.
|
|
5076
6057
|
:param if_seq_no: Only perform the operation if the document has this sequence
|
|
5077
6058
|
number.
|
|
6059
|
+
:param include_source_on_error: True or false if to include the document source
|
|
6060
|
+
in the error message in case of parsing errors.
|
|
5078
6061
|
:param lang: The script language.
|
|
5079
6062
|
:param refresh: If 'true', Elasticsearch refreshes the affected shards to make
|
|
5080
|
-
this operation visible to search
|
|
5081
|
-
make this operation visible to search
|
|
5082
|
-
:param require_alias: If true
|
|
5083
|
-
:param retry_on_conflict:
|
|
6063
|
+
this operation visible to search. If 'wait_for', it waits for a refresh to
|
|
6064
|
+
make this operation visible to search. If 'false', it does nothing with refreshes.
|
|
6065
|
+
:param require_alias: If `true`, the destination must be an index alias.
|
|
6066
|
+
:param retry_on_conflict: The number of times the operation should be retried
|
|
5084
6067
|
when a conflict occurs.
|
|
5085
|
-
:param routing:
|
|
5086
|
-
:param script:
|
|
5087
|
-
:param scripted_upsert:
|
|
5088
|
-
|
|
5089
|
-
:param source:
|
|
5090
|
-
|
|
5091
|
-
:param source_excludes:
|
|
5092
|
-
:param source_includes:
|
|
5093
|
-
:param timeout:
|
|
5094
|
-
|
|
5095
|
-
The actual wait time could be longer, particularly
|
|
6068
|
+
:param routing: A custom value used to route operations to a specific shard.
|
|
6069
|
+
:param script: The script to run to update the document.
|
|
6070
|
+
:param scripted_upsert: If `true`, run the script whether or not the document
|
|
6071
|
+
exists.
|
|
6072
|
+
:param source: If `false`, turn off source retrieval. You can also specify a
|
|
6073
|
+
comma-separated list of the fields you want to retrieve.
|
|
6074
|
+
:param source_excludes: The source fields you want to exclude.
|
|
6075
|
+
:param source_includes: The source fields you want to retrieve.
|
|
6076
|
+
:param timeout: The period to wait for the following operations: dynamic mapping
|
|
6077
|
+
updates and waiting for active shards. Elasticsearch waits for at least the
|
|
6078
|
+
timeout period before failing. The actual wait time could be longer, particularly
|
|
6079
|
+
when multiple waits occur.
|
|
5096
6080
|
:param upsert: If the document does not already exist, the contents of 'upsert'
|
|
5097
|
-
are inserted as a new document. If the document exists, the 'script' is
|
|
5098
|
-
:param wait_for_active_shards: The number of shard
|
|
5099
|
-
before proceeding with the
|
|
5100
|
-
up to the total number of shards in the index (number_of_replicas
|
|
5101
|
-
|
|
6081
|
+
are inserted as a new document. If the document exists, the 'script' is run.
|
|
6082
|
+
:param wait_for_active_shards: The number of copies of each shard that must be
|
|
6083
|
+
active before proceeding with the operation. Set to 'all' or any positive
|
|
6084
|
+
integer up to the total number of shards in the index (`number_of_replicas`+1).
|
|
6085
|
+
The default value of `1` means it waits for each primary shard to be active.
|
|
5102
6086
|
"""
|
|
5103
6087
|
if index in SKIP_IN_PATH:
|
|
5104
6088
|
raise ValueError("Empty value passed for parameter 'index'")
|
|
@@ -5118,6 +6102,8 @@ class AsyncElasticsearch(BaseClient):
|
|
|
5118
6102
|
__query["if_primary_term"] = if_primary_term
|
|
5119
6103
|
if if_seq_no is not None:
|
|
5120
6104
|
__query["if_seq_no"] = if_seq_no
|
|
6105
|
+
if include_source_on_error is not None:
|
|
6106
|
+
__query["include_source_on_error"] = include_source_on_error
|
|
5121
6107
|
if lang is not None:
|
|
5122
6108
|
__query["lang"] = lang
|
|
5123
6109
|
if pretty is not None:
|
|
@@ -5224,82 +6210,166 @@ class AsyncElasticsearch(BaseClient):
|
|
|
5224
6210
|
body: t.Optional[t.Dict[str, t.Any]] = None,
|
|
5225
6211
|
) -> ObjectApiResponse[t.Any]:
|
|
5226
6212
|
"""
|
|
5227
|
-
|
|
5228
|
-
|
|
5229
|
-
|
|
5230
|
-
|
|
5231
|
-
|
|
6213
|
+
.. raw:: html
|
|
6214
|
+
|
|
6215
|
+
<p>Update documents.
|
|
6216
|
+
Updates documents that match the specified query.
|
|
6217
|
+
If no query is specified, performs an update on every document in the data stream or index without modifying the source, which is useful for picking up mapping changes.</p>
|
|
6218
|
+
<p>If the Elasticsearch security features are enabled, you must have the following index privileges for the target data stream, index, or alias:</p>
|
|
6219
|
+
<ul>
|
|
6220
|
+
<li><code>read</code></li>
|
|
6221
|
+
<li><code>index</code> or <code>write</code></li>
|
|
6222
|
+
</ul>
|
|
6223
|
+
<p>You can specify the query criteria in the request URI or the request body using the same syntax as the search API.</p>
|
|
6224
|
+
<p>When you submit an update by query request, Elasticsearch gets a snapshot of the data stream or index when it begins processing the request and updates matching documents using internal versioning.
|
|
6225
|
+
When the versions match, the document is updated and the version number is incremented.
|
|
6226
|
+
If a document changes between the time that the snapshot is taken and the update operation is processed, it results in a version conflict and the operation fails.
|
|
6227
|
+
You can opt to count version conflicts instead of halting and returning by setting <code>conflicts</code> to <code>proceed</code>.
|
|
6228
|
+
Note that if you opt to count version conflicts, the operation could attempt to update more documents from the source than <code>max_docs</code> until it has successfully updated <code>max_docs</code> documents or it has gone through every document in the source query.</p>
|
|
6229
|
+
<p>NOTE: Documents with a version equal to 0 cannot be updated using update by query because internal versioning does not support 0 as a valid version number.</p>
|
|
6230
|
+
<p>While processing an update by query request, Elasticsearch performs multiple search requests sequentially to find all of the matching documents.
|
|
6231
|
+
A bulk update request is performed for each batch of matching documents.
|
|
6232
|
+
Any query or update failures cause the update by query request to fail and the failures are shown in the response.
|
|
6233
|
+
Any update requests that completed successfully still stick, they are not rolled back.</p>
|
|
6234
|
+
<p><strong>Throttling update requests</strong></p>
|
|
6235
|
+
<p>To control the rate at which update by query issues batches of update operations, you can set <code>requests_per_second</code> to any positive decimal number.
|
|
6236
|
+
This pads each batch with a wait time to throttle the rate.
|
|
6237
|
+
Set <code>requests_per_second</code> to <code>-1</code> to turn off throttling.</p>
|
|
6238
|
+
<p>Throttling uses a wait time between batches so that the internal scroll requests can be given a timeout that takes the request padding into account.
|
|
6239
|
+
The padding time is the difference between the batch size divided by the <code>requests_per_second</code> and the time spent writing.
|
|
6240
|
+
By default the batch size is 1000, so if <code>requests_per_second</code> is set to <code>500</code>:</p>
|
|
6241
|
+
<pre><code>target_time = 1000 / 500 per second = 2 seconds
|
|
6242
|
+
wait_time = target_time - write_time = 2 seconds - .5 seconds = 1.5 seconds
|
|
6243
|
+
</code></pre>
|
|
6244
|
+
<p>Since the batch is issued as a single _bulk request, large batch sizes cause Elasticsearch to create many requests and wait before starting the next set.
|
|
6245
|
+
This is "bursty" instead of "smooth".</p>
|
|
6246
|
+
<p><strong>Slicing</strong></p>
|
|
6247
|
+
<p>Update by query supports sliced scroll to parallelize the update process.
|
|
6248
|
+
This can improve efficiency and provide a convenient way to break the request down into smaller parts.</p>
|
|
6249
|
+
<p>Setting <code>slices</code> to <code>auto</code> chooses a reasonable number for most data streams and indices.
|
|
6250
|
+
This setting will use one slice per shard, up to a certain limit.
|
|
6251
|
+
If there are multiple source data streams or indices, it will choose the number of slices based on the index or backing index with the smallest number of shards.</p>
|
|
6252
|
+
<p>Adding <code>slices</code> to <code>_update_by_query</code> just automates the manual process of creating sub-requests, which means it has some quirks:</p>
|
|
6253
|
+
<ul>
|
|
6254
|
+
<li>You can see these requests in the tasks APIs. These sub-requests are "child" tasks of the task for the request with slices.</li>
|
|
6255
|
+
<li>Fetching the status of the task for the request with <code>slices</code> only contains the status of completed slices.</li>
|
|
6256
|
+
<li>These sub-requests are individually addressable for things like cancellation and rethrottling.</li>
|
|
6257
|
+
<li>Rethrottling the request with <code>slices</code> will rethrottle the unfinished sub-request proportionally.</li>
|
|
6258
|
+
<li>Canceling the request with slices will cancel each sub-request.</li>
|
|
6259
|
+
<li>Due to the nature of slices each sub-request won't get a perfectly even portion of the documents. All documents will be addressed, but some slices may be larger than others. Expect larger slices to have a more even distribution.</li>
|
|
6260
|
+
<li>Parameters like <code>requests_per_second</code> and <code>max_docs</code> on a request with slices are distributed proportionally to each sub-request. Combine that with the point above about distribution being uneven and you should conclude that using <code>max_docs</code> with <code>slices</code> might not result in exactly <code>max_docs</code> documents being updated.</li>
|
|
6261
|
+
<li>Each sub-request gets a slightly different snapshot of the source data stream or index though these are all taken at approximately the same time.</li>
|
|
6262
|
+
</ul>
|
|
6263
|
+
<p>If you're slicing manually or otherwise tuning automatic slicing, keep in mind that:</p>
|
|
6264
|
+
<ul>
|
|
6265
|
+
<li>Query performance is most efficient when the number of slices is equal to the number of shards in the index or backing index. If that number is large (for example, 500), choose a lower number as too many slices hurts performance. Setting slices higher than the number of shards generally does not improve efficiency and adds overhead.</li>
|
|
6266
|
+
<li>Update performance scales linearly across available resources with the number of slices.</li>
|
|
6267
|
+
</ul>
|
|
6268
|
+
<p>Whether query or update performance dominates the runtime depends on the documents being reindexed and cluster resources.</p>
|
|
6269
|
+
<p><strong>Update the document source</strong></p>
|
|
6270
|
+
<p>Update by query supports scripts to update the document source.
|
|
6271
|
+
As with the update API, you can set <code>ctx.op</code> to change the operation that is performed.</p>
|
|
6272
|
+
<p>Set <code>ctx.op = "noop"</code> if your script decides that it doesn't have to make any changes.
|
|
6273
|
+
The update by query operation skips updating the document and increments the <code>noop</code> counter.</p>
|
|
6274
|
+
<p>Set <code>ctx.op = "delete"</code> if your script decides that the document should be deleted.
|
|
6275
|
+
The update by query operation deletes the document and increments the <code>deleted</code> counter.</p>
|
|
6276
|
+
<p>Update by query supports only <code>index</code>, <code>noop</code>, and <code>delete</code>.
|
|
6277
|
+
Setting <code>ctx.op</code> to anything else is an error.
|
|
6278
|
+
Setting any other field in <code>ctx</code> is an error.
|
|
6279
|
+
This API enables you to only modify the source of matching documents; you cannot move them.</p>
|
|
6280
|
+
|
|
6281
|
+
|
|
6282
|
+
`<https://www.elastic.co/docs/api/doc/elasticsearch/v9/operation/operation-update-by-query>`_
|
|
5232
6283
|
|
|
5233
|
-
:param index:
|
|
5234
|
-
|
|
5235
|
-
parameter or use `*` or `_all`.
|
|
6284
|
+
:param index: A comma-separated list of data streams, indices, and aliases to
|
|
6285
|
+
search. It supports wildcards (`*`). To search all data streams or indices,
|
|
6286
|
+
omit this parameter or use `*` or `_all`.
|
|
5236
6287
|
:param allow_no_indices: If `false`, the request returns an error if any wildcard
|
|
5237
6288
|
expression, index alias, or `_all` value targets only missing or closed indices.
|
|
5238
6289
|
This behavior applies even if the request targets other open indices. For
|
|
5239
6290
|
example, a request targeting `foo*,bar*` returns an error if an index starts
|
|
5240
6291
|
with `foo` but no index starts with `bar`.
|
|
5241
6292
|
:param analyze_wildcard: If `true`, wildcard and prefix queries are analyzed.
|
|
5242
|
-
|
|
5243
|
-
:param
|
|
5244
|
-
|
|
6293
|
+
This parameter can be used only when the `q` query string parameter is specified.
|
|
6294
|
+
:param analyzer: The analyzer to use for the query string. This parameter can
|
|
6295
|
+
be used only when the `q` query string parameter is specified.
|
|
6296
|
+
:param conflicts: The preferred behavior when update by query hits version conflicts:
|
|
6297
|
+
`abort` or `proceed`.
|
|
5245
6298
|
:param default_operator: The default operator for query string query: `AND` or
|
|
5246
|
-
`OR`.
|
|
5247
|
-
|
|
5248
|
-
|
|
5249
|
-
|
|
5250
|
-
|
|
5251
|
-
|
|
5252
|
-
|
|
5253
|
-
|
|
6299
|
+
`OR`. This parameter can be used only when the `q` query string parameter
|
|
6300
|
+
is specified.
|
|
6301
|
+
:param df: The field to use as default where no field prefix is given in the
|
|
6302
|
+
query string. This parameter can be used only when the `q` query string parameter
|
|
6303
|
+
is specified.
|
|
6304
|
+
:param expand_wildcards: The type of index that wildcard patterns can match.
|
|
6305
|
+
If the request can target data streams, this argument determines whether
|
|
6306
|
+
wildcard expressions match hidden data streams. It supports comma-separated
|
|
6307
|
+
values, such as `open,hidden`. Valid values are: `all`, `open`, `closed`,
|
|
6308
|
+
`hidden`, `none`.
|
|
6309
|
+
:param from_: Skips the specified number of documents.
|
|
5254
6310
|
:param ignore_unavailable: If `false`, the request returns an error if it targets
|
|
5255
6311
|
a missing or closed index.
|
|
5256
6312
|
:param lenient: If `true`, format-based query failures (such as providing text
|
|
5257
|
-
to a numeric field) in the query string will be ignored.
|
|
6313
|
+
to a numeric field) in the query string will be ignored. This parameter can
|
|
6314
|
+
be used only when the `q` query string parameter is specified.
|
|
5258
6315
|
:param max_docs: The maximum number of documents to update.
|
|
5259
|
-
:param pipeline: ID of the pipeline to use to preprocess incoming documents.
|
|
6316
|
+
:param pipeline: The ID of the pipeline to use to preprocess incoming documents.
|
|
5260
6317
|
If the index has a default ingest pipeline specified, then setting the value
|
|
5261
6318
|
to `_none` disables the default ingest pipeline for this request. If a final
|
|
5262
6319
|
pipeline is configured it will always run, regardless of the value of this
|
|
5263
6320
|
parameter.
|
|
5264
|
-
:param preference:
|
|
5265
|
-
|
|
5266
|
-
:param q:
|
|
5267
|
-
:param query:
|
|
6321
|
+
:param preference: The node or shard the operation should be performed on. It
|
|
6322
|
+
is random by default.
|
|
6323
|
+
:param q: A query in the Lucene query string syntax.
|
|
6324
|
+
:param query: The documents to update using the Query DSL.
|
|
5268
6325
|
:param refresh: If `true`, Elasticsearch refreshes affected shards to make the
|
|
5269
|
-
operation visible to search.
|
|
6326
|
+
operation visible to search after the request completes. This is different
|
|
6327
|
+
than the update API's `refresh` parameter, which causes just the shard that
|
|
6328
|
+
received the request to be refreshed.
|
|
5270
6329
|
:param request_cache: If `true`, the request cache is used for this request.
|
|
6330
|
+
It defaults to the index-level setting.
|
|
5271
6331
|
:param requests_per_second: The throttle for this request in sub-requests per
|
|
5272
6332
|
second.
|
|
5273
|
-
:param routing:
|
|
6333
|
+
:param routing: A custom value used to route operations to a specific shard.
|
|
5274
6334
|
:param script: The script to run to update the document source or metadata when
|
|
5275
6335
|
updating.
|
|
5276
|
-
:param scroll:
|
|
5277
|
-
:param scroll_size:
|
|
5278
|
-
:param search_timeout:
|
|
5279
|
-
|
|
5280
|
-
|
|
6336
|
+
:param scroll: The period to retain the search context for scrolling.
|
|
6337
|
+
:param scroll_size: The size of the scroll request that powers the operation.
|
|
6338
|
+
:param search_timeout: An explicit timeout for each search request. By default,
|
|
6339
|
+
there is no timeout.
|
|
6340
|
+
:param search_type: The type of the search operation. Available options include
|
|
6341
|
+
`query_then_fetch` and `dfs_query_then_fetch`.
|
|
5281
6342
|
:param slice: Slice the request manually using the provided slice ID and total
|
|
5282
6343
|
number of slices.
|
|
5283
6344
|
:param slices: The number of slices this task should be divided into.
|
|
5284
6345
|
:param sort: A comma-separated list of <field>:<direction> pairs.
|
|
5285
|
-
:param stats:
|
|
5286
|
-
:param terminate_after:
|
|
6346
|
+
:param stats: The specific `tag` of the request for logging and statistical purposes.
|
|
6347
|
+
:param terminate_after: The maximum number of documents to collect for each shard.
|
|
5287
6348
|
If a query reaches this limit, Elasticsearch terminates the query early.
|
|
5288
|
-
Elasticsearch collects documents before sorting. Use with caution.
|
|
5289
|
-
applies this parameter to each shard handling the request.
|
|
5290
|
-
let Elasticsearch perform early termination automatically.
|
|
5291
|
-
this parameter for requests that target data streams with
|
|
5292
|
-
across multiple data tiers.
|
|
5293
|
-
:param timeout:
|
|
5294
|
-
dynamic mapping updates, waiting for active shards.
|
|
6349
|
+
Elasticsearch collects documents before sorting. IMPORTANT: Use with caution.
|
|
6350
|
+
Elasticsearch applies this parameter to each shard handling the request.
|
|
6351
|
+
When possible, let Elasticsearch perform early termination automatically.
|
|
6352
|
+
Avoid specifying this parameter for requests that target data streams with
|
|
6353
|
+
backing indices across multiple data tiers.
|
|
6354
|
+
:param timeout: The period each update request waits for the following operations:
|
|
6355
|
+
dynamic mapping updates, waiting for active shards. By default, it is one
|
|
6356
|
+
minute. This guarantees Elasticsearch waits for at least the timeout before
|
|
6357
|
+
failing. The actual wait time could be longer, particularly when multiple
|
|
6358
|
+
waits occur.
|
|
5295
6359
|
:param version: If `true`, returns the document version as part of a hit.
|
|
5296
6360
|
:param version_type: Should the document increment the version number (internal)
|
|
5297
6361
|
on hit or not (reindex)
|
|
5298
6362
|
:param wait_for_active_shards: The number of shard copies that must be active
|
|
5299
6363
|
before proceeding with the operation. Set to `all` or any positive integer
|
|
5300
|
-
up to the total number of shards in the index (`number_of_replicas+1`).
|
|
6364
|
+
up to the total number of shards in the index (`number_of_replicas+1`). The
|
|
6365
|
+
`timeout` parameter controls how long each write request waits for unavailable
|
|
6366
|
+
shards to become available. Both work exactly the way they work in the bulk
|
|
6367
|
+
API.
|
|
5301
6368
|
:param wait_for_completion: If `true`, the request blocks until the operation
|
|
5302
|
-
is complete.
|
|
6369
|
+
is complete. If `false`, Elasticsearch performs some preflight checks, launches
|
|
6370
|
+
the request, and returns a task ID that you can use to cancel or get the
|
|
6371
|
+
status of the task. Elasticsearch creates a record of this task as a document
|
|
6372
|
+
at `.tasks/task/${taskId}`.
|
|
5303
6373
|
"""
|
|
5304
6374
|
if index in SKIP_IN_PATH:
|
|
5305
6375
|
raise ValueError("Empty value passed for parameter 'index'")
|
|
@@ -5422,16 +6492,18 @@ class AsyncElasticsearch(BaseClient):
|
|
|
5422
6492
|
requests_per_second: t.Optional[float] = None,
|
|
5423
6493
|
) -> ObjectApiResponse[t.Any]:
|
|
5424
6494
|
"""
|
|
5425
|
-
|
|
5426
|
-
|
|
5427
|
-
|
|
5428
|
-
|
|
6495
|
+
.. raw:: html
|
|
6496
|
+
|
|
6497
|
+
<p>Throttle an update by query operation.</p>
|
|
6498
|
+
<p>Change the number of requests per second for a particular update by query operation.
|
|
6499
|
+
Rethrottling that speeds up the query takes effect immediately but rethrotting that slows down the query takes effect after completing the current batch to prevent scroll timeouts.</p>
|
|
5429
6500
|
|
|
5430
|
-
|
|
6501
|
+
|
|
6502
|
+
`<https://www.elastic.co/docs/api/doc/elasticsearch/v9/operation/operation-update-by-query-rethrottle>`_
|
|
5431
6503
|
|
|
5432
6504
|
:param task_id: The ID for the task.
|
|
5433
6505
|
:param requests_per_second: The throttle for this request in sub-requests per
|
|
5434
|
-
second.
|
|
6506
|
+
second. To turn off throttling, set it to `-1`.
|
|
5435
6507
|
"""
|
|
5436
6508
|
if task_id in SKIP_IN_PATH:
|
|
5437
6509
|
raise ValueError("Empty value passed for parameter 'task_id'")
|