elasticsearch 8.12.1__py3-none-any.whl → 8.13.1__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.
Files changed (105) hide show
  1. elasticsearch/__init__.py +7 -0
  2. elasticsearch/_async/client/__init__.py +477 -128
  3. elasticsearch/_async/client/_base.py +41 -1
  4. elasticsearch/_async/client/async_search.py +40 -12
  5. elasticsearch/_async/client/autoscaling.py +37 -11
  6. elasticsearch/_async/client/cat.py +260 -69
  7. elasticsearch/_async/client/ccr.py +123 -38
  8. elasticsearch/_async/client/cluster.py +153 -42
  9. elasticsearch/_async/client/dangling_indices.py +27 -8
  10. elasticsearch/_async/client/enrich.py +48 -14
  11. elasticsearch/_async/client/eql.py +38 -12
  12. elasticsearch/_async/client/esql.py +10 -2
  13. elasticsearch/_async/client/features.py +17 -4
  14. elasticsearch/_async/client/fleet.py +30 -7
  15. elasticsearch/_async/client/graph.py +11 -3
  16. elasticsearch/_async/client/ilm.py +101 -29
  17. elasticsearch/_async/client/indices.py +688 -181
  18. elasticsearch/_async/client/inference.py +111 -44
  19. elasticsearch/_async/client/ingest.py +59 -16
  20. elasticsearch/_async/client/license.py +58 -14
  21. elasticsearch/_async/client/logstash.py +31 -9
  22. elasticsearch/_async/client/migration.py +28 -7
  23. elasticsearch/_async/client/ml.py +781 -214
  24. elasticsearch/_async/client/monitoring.py +10 -2
  25. elasticsearch/_async/client/nodes.py +103 -29
  26. elasticsearch/_async/client/query_ruleset.py +37 -11
  27. elasticsearch/_async/client/rollup.py +79 -24
  28. elasticsearch/_async/client/search_application.py +76 -23
  29. elasticsearch/_async/client/searchable_snapshots.py +49 -12
  30. elasticsearch/_async/client/security.py +544 -143
  31. elasticsearch/_async/client/shutdown.py +28 -6
  32. elasticsearch/_async/client/slm.py +80 -22
  33. elasticsearch/_async/client/snapshot.py +140 -54
  34. elasticsearch/_async/client/sql.py +55 -15
  35. elasticsearch/_async/client/ssl.py +9 -2
  36. elasticsearch/_async/client/synonyms.py +75 -21
  37. elasticsearch/_async/client/tasks.py +29 -8
  38. elasticsearch/_async/client/text_structure.py +74 -2
  39. elasticsearch/_async/client/transform.py +106 -32
  40. elasticsearch/_async/client/watcher.py +110 -31
  41. elasticsearch/_async/client/xpack.py +16 -4
  42. elasticsearch/_async/helpers.py +1 -1
  43. elasticsearch/_otel.py +92 -0
  44. elasticsearch/_sync/client/__init__.py +477 -128
  45. elasticsearch/_sync/client/_base.py +41 -1
  46. elasticsearch/_sync/client/async_search.py +40 -12
  47. elasticsearch/_sync/client/autoscaling.py +37 -11
  48. elasticsearch/_sync/client/cat.py +260 -69
  49. elasticsearch/_sync/client/ccr.py +123 -38
  50. elasticsearch/_sync/client/cluster.py +153 -42
  51. elasticsearch/_sync/client/dangling_indices.py +27 -8
  52. elasticsearch/_sync/client/enrich.py +48 -14
  53. elasticsearch/_sync/client/eql.py +38 -12
  54. elasticsearch/_sync/client/esql.py +10 -2
  55. elasticsearch/_sync/client/features.py +17 -4
  56. elasticsearch/_sync/client/fleet.py +30 -7
  57. elasticsearch/_sync/client/graph.py +11 -3
  58. elasticsearch/_sync/client/ilm.py +101 -29
  59. elasticsearch/_sync/client/indices.py +688 -181
  60. elasticsearch/_sync/client/inference.py +111 -44
  61. elasticsearch/_sync/client/ingest.py +59 -16
  62. elasticsearch/_sync/client/license.py +58 -14
  63. elasticsearch/_sync/client/logstash.py +31 -9
  64. elasticsearch/_sync/client/migration.py +28 -7
  65. elasticsearch/_sync/client/ml.py +781 -214
  66. elasticsearch/_sync/client/monitoring.py +10 -2
  67. elasticsearch/_sync/client/nodes.py +103 -29
  68. elasticsearch/_sync/client/query_ruleset.py +37 -11
  69. elasticsearch/_sync/client/rollup.py +79 -24
  70. elasticsearch/_sync/client/search_application.py +76 -23
  71. elasticsearch/_sync/client/searchable_snapshots.py +49 -12
  72. elasticsearch/_sync/client/security.py +544 -143
  73. elasticsearch/_sync/client/shutdown.py +28 -6
  74. elasticsearch/_sync/client/slm.py +80 -22
  75. elasticsearch/_sync/client/snapshot.py +140 -54
  76. elasticsearch/_sync/client/sql.py +55 -15
  77. elasticsearch/_sync/client/ssl.py +9 -2
  78. elasticsearch/_sync/client/synonyms.py +75 -21
  79. elasticsearch/_sync/client/tasks.py +29 -8
  80. elasticsearch/_sync/client/text_structure.py +74 -2
  81. elasticsearch/_sync/client/transform.py +106 -32
  82. elasticsearch/_sync/client/watcher.py +110 -31
  83. elasticsearch/_sync/client/xpack.py +16 -4
  84. elasticsearch/_version.py +1 -1
  85. elasticsearch/helpers/actions.py +1 -1
  86. elasticsearch/helpers/vectorstore/__init__.py +62 -0
  87. elasticsearch/helpers/vectorstore/_async/__init__.py +16 -0
  88. elasticsearch/helpers/vectorstore/_async/_utils.py +39 -0
  89. elasticsearch/helpers/vectorstore/_async/embedding_service.py +89 -0
  90. elasticsearch/helpers/vectorstore/_async/strategies.py +466 -0
  91. elasticsearch/helpers/vectorstore/_async/vectorstore.py +391 -0
  92. elasticsearch/helpers/vectorstore/_sync/__init__.py +16 -0
  93. elasticsearch/helpers/vectorstore/_sync/_utils.py +39 -0
  94. elasticsearch/helpers/vectorstore/_sync/embedding_service.py +89 -0
  95. elasticsearch/helpers/vectorstore/_sync/strategies.py +466 -0
  96. elasticsearch/helpers/vectorstore/_sync/vectorstore.py +388 -0
  97. elasticsearch/helpers/vectorstore/_utils.py +116 -0
  98. elasticsearch/serializer.py +14 -0
  99. {elasticsearch-8.12.1.dist-info → elasticsearch-8.13.1.dist-info}/METADATA +28 -8
  100. elasticsearch-8.13.1.dist-info/RECORD +116 -0
  101. {elasticsearch-8.12.1.dist-info → elasticsearch-8.13.1.dist-info}/WHEEL +1 -1
  102. elasticsearch-8.12.1.dist-info/RECORD +0 -103
  103. {elasticsearch-8.12.1.dist-info → elasticsearch-8.13.1.dist-info}/LICENSE +0 -0
  104. {elasticsearch-8.12.1.dist-info → elasticsearch-8.13.1.dist-info}/NOTICE +0 -0
  105. {elasticsearch-8.12.1.dist-info → elasticsearch-8.13.1.dist-info}/top_level.txt +0 -0
@@ -24,6 +24,7 @@ from .utils import SKIP_IN_PATH, _quote, _rewrite_parameters
24
24
 
25
25
 
26
26
  class WatcherClient(NamespacedClient):
27
+
27
28
  @_rewrite_parameters()
28
29
  def ack_watch(
29
30
  self,
@@ -38,17 +39,23 @@ class WatcherClient(NamespacedClient):
38
39
  """
39
40
  Acknowledges a watch, manually throttling the execution of the watch's actions.
40
41
 
41
- `<https://www.elastic.co/guide/en/elasticsearch/reference/8.12/watcher-api-ack-watch.html>`_
42
+ `<https://www.elastic.co/guide/en/elasticsearch/reference/8.13/watcher-api-ack-watch.html>`_
42
43
 
43
44
  :param watch_id: Watch ID
44
45
  :param action_id: A comma-separated list of the action ids to be acked
45
46
  """
46
47
  if watch_id in SKIP_IN_PATH:
47
48
  raise ValueError("Empty value passed for parameter 'watch_id'")
49
+ __path_parts: t.Dict[str, str]
48
50
  if watch_id not in SKIP_IN_PATH and action_id not in SKIP_IN_PATH:
49
- __path = f"/_watcher/watch/{_quote(watch_id)}/_ack/{_quote(action_id)}"
51
+ __path_parts = {
52
+ "watch_id": _quote(watch_id),
53
+ "action_id": _quote(action_id),
54
+ }
55
+ __path = f'/_watcher/watch/{__path_parts["watch_id"]}/_ack/{__path_parts["action_id"]}'
50
56
  elif watch_id not in SKIP_IN_PATH:
51
- __path = f"/_watcher/watch/{_quote(watch_id)}/_ack"
57
+ __path_parts = {"watch_id": _quote(watch_id)}
58
+ __path = f'/_watcher/watch/{__path_parts["watch_id"]}/_ack'
52
59
  else:
53
60
  raise ValueError("Couldn't find a path for the given parameters")
54
61
  __query: t.Dict[str, t.Any] = {}
@@ -62,7 +69,12 @@ class WatcherClient(NamespacedClient):
62
69
  __query["pretty"] = pretty
63
70
  __headers = {"accept": "application/json"}
64
71
  return self.perform_request( # type: ignore[return-value]
65
- "PUT", __path, params=__query, headers=__headers
72
+ "PUT",
73
+ __path,
74
+ params=__query,
75
+ headers=__headers,
76
+ endpoint_id="watcher.ack_watch",
77
+ path_parts=__path_parts,
66
78
  )
67
79
 
68
80
  @_rewrite_parameters()
@@ -78,13 +90,14 @@ class WatcherClient(NamespacedClient):
78
90
  """
79
91
  Activates a currently inactive watch.
80
92
 
81
- `<https://www.elastic.co/guide/en/elasticsearch/reference/8.12/watcher-api-activate-watch.html>`_
93
+ `<https://www.elastic.co/guide/en/elasticsearch/reference/8.13/watcher-api-activate-watch.html>`_
82
94
 
83
95
  :param watch_id: Watch ID
84
96
  """
85
97
  if watch_id in SKIP_IN_PATH:
86
98
  raise ValueError("Empty value passed for parameter 'watch_id'")
87
- __path = f"/_watcher/watch/{_quote(watch_id)}/_activate"
99
+ __path_parts: t.Dict[str, str] = {"watch_id": _quote(watch_id)}
100
+ __path = f'/_watcher/watch/{__path_parts["watch_id"]}/_activate'
88
101
  __query: t.Dict[str, t.Any] = {}
89
102
  if error_trace is not None:
90
103
  __query["error_trace"] = error_trace
@@ -96,7 +109,12 @@ class WatcherClient(NamespacedClient):
96
109
  __query["pretty"] = pretty
97
110
  __headers = {"accept": "application/json"}
98
111
  return self.perform_request( # type: ignore[return-value]
99
- "PUT", __path, params=__query, headers=__headers
112
+ "PUT",
113
+ __path,
114
+ params=__query,
115
+ headers=__headers,
116
+ endpoint_id="watcher.activate_watch",
117
+ path_parts=__path_parts,
100
118
  )
101
119
 
102
120
  @_rewrite_parameters()
@@ -112,13 +130,14 @@ class WatcherClient(NamespacedClient):
112
130
  """
113
131
  Deactivates a currently active watch.
114
132
 
115
- `<https://www.elastic.co/guide/en/elasticsearch/reference/8.12/watcher-api-deactivate-watch.html>`_
133
+ `<https://www.elastic.co/guide/en/elasticsearch/reference/8.13/watcher-api-deactivate-watch.html>`_
116
134
 
117
135
  :param watch_id: Watch ID
118
136
  """
119
137
  if watch_id in SKIP_IN_PATH:
120
138
  raise ValueError("Empty value passed for parameter 'watch_id'")
121
- __path = f"/_watcher/watch/{_quote(watch_id)}/_deactivate"
139
+ __path_parts: t.Dict[str, str] = {"watch_id": _quote(watch_id)}
140
+ __path = f'/_watcher/watch/{__path_parts["watch_id"]}/_deactivate'
122
141
  __query: t.Dict[str, t.Any] = {}
123
142
  if error_trace is not None:
124
143
  __query["error_trace"] = error_trace
@@ -130,7 +149,12 @@ class WatcherClient(NamespacedClient):
130
149
  __query["pretty"] = pretty
131
150
  __headers = {"accept": "application/json"}
132
151
  return self.perform_request( # type: ignore[return-value]
133
- "PUT", __path, params=__query, headers=__headers
152
+ "PUT",
153
+ __path,
154
+ params=__query,
155
+ headers=__headers,
156
+ endpoint_id="watcher.deactivate_watch",
157
+ path_parts=__path_parts,
134
158
  )
135
159
 
136
160
  @_rewrite_parameters()
@@ -146,13 +170,14 @@ class WatcherClient(NamespacedClient):
146
170
  """
147
171
  Removes a watch from Watcher.
148
172
 
149
- `<https://www.elastic.co/guide/en/elasticsearch/reference/8.12/watcher-api-delete-watch.html>`_
173
+ `<https://www.elastic.co/guide/en/elasticsearch/reference/8.13/watcher-api-delete-watch.html>`_
150
174
 
151
175
  :param id: Watch ID
152
176
  """
153
177
  if id in SKIP_IN_PATH:
154
178
  raise ValueError("Empty value passed for parameter 'id'")
155
- __path = f"/_watcher/watch/{_quote(id)}"
179
+ __path_parts: t.Dict[str, str] = {"id": _quote(id)}
180
+ __path = f'/_watcher/watch/{__path_parts["id"]}'
156
181
  __query: t.Dict[str, t.Any] = {}
157
182
  if error_trace is not None:
158
183
  __query["error_trace"] = error_trace
@@ -164,7 +189,12 @@ class WatcherClient(NamespacedClient):
164
189
  __query["pretty"] = pretty
165
190
  __headers = {"accept": "application/json"}
166
191
  return self.perform_request( # type: ignore[return-value]
167
- "DELETE", __path, params=__query, headers=__headers
192
+ "DELETE",
193
+ __path,
194
+ params=__query,
195
+ headers=__headers,
196
+ endpoint_id="watcher.delete_watch",
197
+ path_parts=__path_parts,
168
198
  )
169
199
 
170
200
  @_rewrite_parameters(
@@ -207,7 +237,7 @@ class WatcherClient(NamespacedClient):
207
237
  """
208
238
  Forces the execution of a stored watch.
209
239
 
210
- `<https://www.elastic.co/guide/en/elasticsearch/reference/8.12/watcher-api-execute-watch.html>`_
240
+ `<https://www.elastic.co/guide/en/elasticsearch/reference/8.13/watcher-api-execute-watch.html>`_
211
241
 
212
242
  :param id: Identifier for the watch.
213
243
  :param action_modes: Determines how to handle the watch actions as part of the
@@ -228,9 +258,12 @@ class WatcherClient(NamespacedClient):
228
258
  the request. This watch is not persisted to the index and record_execution
229
259
  cannot be set.
230
260
  """
261
+ __path_parts: t.Dict[str, str]
231
262
  if id not in SKIP_IN_PATH:
232
- __path = f"/_watcher/watch/{_quote(id)}/_execute"
263
+ __path_parts = {"id": _quote(id)}
264
+ __path = f'/_watcher/watch/{__path_parts["id"]}/_execute'
233
265
  else:
266
+ __path_parts = {}
234
267
  __path = "/_watcher/watch/_execute"
235
268
  __query: t.Dict[str, t.Any] = {}
236
269
  __body: t.Dict[str, t.Any] = body if body is not None else {}
@@ -265,7 +298,13 @@ class WatcherClient(NamespacedClient):
265
298
  if __body is not None:
266
299
  __headers["content-type"] = "application/json"
267
300
  return self.perform_request( # type: ignore[return-value]
268
- "PUT", __path, params=__query, headers=__headers, body=__body
301
+ "PUT",
302
+ __path,
303
+ params=__query,
304
+ headers=__headers,
305
+ body=__body,
306
+ endpoint_id="watcher.execute_watch",
307
+ path_parts=__path_parts,
269
308
  )
270
309
 
271
310
  @_rewrite_parameters()
@@ -281,13 +320,14 @@ class WatcherClient(NamespacedClient):
281
320
  """
282
321
  Retrieves a watch by its ID.
283
322
 
284
- `<https://www.elastic.co/guide/en/elasticsearch/reference/8.12/watcher-api-get-watch.html>`_
323
+ `<https://www.elastic.co/guide/en/elasticsearch/reference/8.13/watcher-api-get-watch.html>`_
285
324
 
286
325
  :param id: Watch ID
287
326
  """
288
327
  if id in SKIP_IN_PATH:
289
328
  raise ValueError("Empty value passed for parameter 'id'")
290
- __path = f"/_watcher/watch/{_quote(id)}"
329
+ __path_parts: t.Dict[str, str] = {"id": _quote(id)}
330
+ __path = f'/_watcher/watch/{__path_parts["id"]}'
291
331
  __query: t.Dict[str, t.Any] = {}
292
332
  if error_trace is not None:
293
333
  __query["error_trace"] = error_trace
@@ -299,7 +339,12 @@ class WatcherClient(NamespacedClient):
299
339
  __query["pretty"] = pretty
300
340
  __headers = {"accept": "application/json"}
301
341
  return self.perform_request( # type: ignore[return-value]
302
- "GET", __path, params=__query, headers=__headers
342
+ "GET",
343
+ __path,
344
+ params=__query,
345
+ headers=__headers,
346
+ endpoint_id="watcher.get_watch",
347
+ path_parts=__path_parts,
303
348
  )
304
349
 
305
350
  @_rewrite_parameters(
@@ -337,7 +382,7 @@ class WatcherClient(NamespacedClient):
337
382
  """
338
383
  Creates a new watch, or updates an existing one.
339
384
 
340
- `<https://www.elastic.co/guide/en/elasticsearch/reference/8.12/watcher-api-put-watch.html>`_
385
+ `<https://www.elastic.co/guide/en/elasticsearch/reference/8.13/watcher-api-put-watch.html>`_
341
386
 
342
387
  :param id: Watch ID
343
388
  :param actions:
@@ -356,7 +401,8 @@ class WatcherClient(NamespacedClient):
356
401
  """
357
402
  if id in SKIP_IN_PATH:
358
403
  raise ValueError("Empty value passed for parameter 'id'")
359
- __path = f"/_watcher/watch/{_quote(id)}"
404
+ __path_parts: t.Dict[str, str] = {"id": _quote(id)}
405
+ __path = f'/_watcher/watch/{__path_parts["id"]}'
360
406
  __query: t.Dict[str, t.Any] = {}
361
407
  __body: t.Dict[str, t.Any] = body if body is not None else {}
362
408
  if active is not None:
@@ -396,7 +442,13 @@ class WatcherClient(NamespacedClient):
396
442
  if __body is not None:
397
443
  __headers["content-type"] = "application/json"
398
444
  return self.perform_request( # type: ignore[return-value]
399
- "PUT", __path, params=__query, headers=__headers, body=__body
445
+ "PUT",
446
+ __path,
447
+ params=__query,
448
+ headers=__headers,
449
+ body=__body,
450
+ endpoint_id="watcher.put_watch",
451
+ path_parts=__path_parts,
400
452
  )
401
453
 
402
454
  @_rewrite_parameters(
@@ -427,7 +479,7 @@ class WatcherClient(NamespacedClient):
427
479
  """
428
480
  Retrieves stored watches.
429
481
 
430
- `<https://www.elastic.co/guide/en/elasticsearch/reference/8.12/watcher-api-query-watches.html>`_
482
+ `<https://www.elastic.co/guide/en/elasticsearch/reference/8.13/watcher-api-query-watches.html>`_
431
483
 
432
484
  :param from_: The offset from the first result to fetch. Needs to be non-negative.
433
485
  :param query: Optional, query filter watches to be returned.
@@ -436,6 +488,7 @@ class WatcherClient(NamespacedClient):
436
488
  :param size: The number of hits to return. Needs to be non-negative.
437
489
  :param sort: Optional sort definition.
438
490
  """
491
+ __path_parts: t.Dict[str, str] = {}
439
492
  __path = "/_watcher/_query/watches"
440
493
  __query: t.Dict[str, t.Any] = {}
441
494
  __body: t.Dict[str, t.Any] = body if body is not None else {}
@@ -475,7 +528,13 @@ class WatcherClient(NamespacedClient):
475
528
  if __body is not None:
476
529
  __headers["content-type"] = "application/json"
477
530
  return self.perform_request( # type: ignore[return-value]
478
- "POST", __path, params=__query, headers=__headers, body=__body
531
+ "POST",
532
+ __path,
533
+ params=__query,
534
+ headers=__headers,
535
+ body=__body,
536
+ endpoint_id="watcher.query_watches",
537
+ path_parts=__path_parts,
479
538
  )
480
539
 
481
540
  @_rewrite_parameters()
@@ -490,8 +549,9 @@ class WatcherClient(NamespacedClient):
490
549
  """
491
550
  Starts Watcher if it is not already running.
492
551
 
493
- `<https://www.elastic.co/guide/en/elasticsearch/reference/8.12/watcher-api-start.html>`_
552
+ `<https://www.elastic.co/guide/en/elasticsearch/reference/8.13/watcher-api-start.html>`_
494
553
  """
554
+ __path_parts: t.Dict[str, str] = {}
495
555
  __path = "/_watcher/_start"
496
556
  __query: t.Dict[str, t.Any] = {}
497
557
  if error_trace is not None:
@@ -504,7 +564,12 @@ class WatcherClient(NamespacedClient):
504
564
  __query["pretty"] = pretty
505
565
  __headers = {"accept": "application/json"}
506
566
  return self.perform_request( # type: ignore[return-value]
507
- "POST", __path, params=__query, headers=__headers
567
+ "POST",
568
+ __path,
569
+ params=__query,
570
+ headers=__headers,
571
+ endpoint_id="watcher.start",
572
+ path_parts=__path_parts,
508
573
  )
509
574
 
510
575
  @_rewrite_parameters()
@@ -534,15 +599,18 @@ class WatcherClient(NamespacedClient):
534
599
  """
535
600
  Retrieves the current Watcher metrics.
536
601
 
537
- `<https://www.elastic.co/guide/en/elasticsearch/reference/8.12/watcher-api-stats.html>`_
602
+ `<https://www.elastic.co/guide/en/elasticsearch/reference/8.13/watcher-api-stats.html>`_
538
603
 
539
604
  :param metric: Defines which additional metrics are included in the response.
540
605
  :param emit_stacktraces: Defines whether stack traces are generated for each
541
606
  watch that is running.
542
607
  """
608
+ __path_parts: t.Dict[str, str]
543
609
  if metric not in SKIP_IN_PATH:
544
- __path = f"/_watcher/stats/{_quote(metric)}"
610
+ __path_parts = {"metric": _quote(metric)}
611
+ __path = f'/_watcher/stats/{__path_parts["metric"]}'
545
612
  else:
613
+ __path_parts = {}
546
614
  __path = "/_watcher/stats"
547
615
  __query: t.Dict[str, t.Any] = {}
548
616
  if emit_stacktraces is not None:
@@ -557,7 +625,12 @@ class WatcherClient(NamespacedClient):
557
625
  __query["pretty"] = pretty
558
626
  __headers = {"accept": "application/json"}
559
627
  return self.perform_request( # type: ignore[return-value]
560
- "GET", __path, params=__query, headers=__headers
628
+ "GET",
629
+ __path,
630
+ params=__query,
631
+ headers=__headers,
632
+ endpoint_id="watcher.stats",
633
+ path_parts=__path_parts,
561
634
  )
562
635
 
563
636
  @_rewrite_parameters()
@@ -572,8 +645,9 @@ class WatcherClient(NamespacedClient):
572
645
  """
573
646
  Stops Watcher if it is running.
574
647
 
575
- `<https://www.elastic.co/guide/en/elasticsearch/reference/8.12/watcher-api-stop.html>`_
648
+ `<https://www.elastic.co/guide/en/elasticsearch/reference/8.13/watcher-api-stop.html>`_
576
649
  """
650
+ __path_parts: t.Dict[str, str] = {}
577
651
  __path = "/_watcher/_stop"
578
652
  __query: t.Dict[str, t.Any] = {}
579
653
  if error_trace is not None:
@@ -586,5 +660,10 @@ class WatcherClient(NamespacedClient):
586
660
  __query["pretty"] = pretty
587
661
  __headers = {"accept": "application/json"}
588
662
  return self.perform_request( # type: ignore[return-value]
589
- "POST", __path, params=__query, headers=__headers
663
+ "POST",
664
+ __path,
665
+ params=__query,
666
+ headers=__headers,
667
+ endpoint_id="watcher.stop",
668
+ path_parts=__path_parts,
590
669
  )
@@ -43,12 +43,13 @@ class XPackClient(NamespacedClient):
43
43
  """
44
44
  Retrieves information about the installed X-Pack features.
45
45
 
46
- `<https://www.elastic.co/guide/en/elasticsearch/reference/8.12/info-api.html>`_
46
+ `<https://www.elastic.co/guide/en/elasticsearch/reference/8.13/info-api.html>`_
47
47
 
48
48
  :param accept_enterprise: If this param is used it must be set to true
49
49
  :param categories: A comma-separated list of the information categories to include
50
50
  in the response. For example, `build,license,features`.
51
51
  """
52
+ __path_parts: t.Dict[str, str] = {}
52
53
  __path = "/_xpack"
53
54
  __query: t.Dict[str, t.Any] = {}
54
55
  if accept_enterprise is not None:
@@ -65,7 +66,12 @@ class XPackClient(NamespacedClient):
65
66
  __query["pretty"] = pretty
66
67
  __headers = {"accept": "application/json"}
67
68
  return self.perform_request( # type: ignore[return-value]
68
- "GET", __path, params=__query, headers=__headers
69
+ "GET",
70
+ __path,
71
+ params=__query,
72
+ headers=__headers,
73
+ endpoint_id="xpack.info",
74
+ path_parts=__path_parts,
69
75
  )
70
76
 
71
77
  @_rewrite_parameters()
@@ -83,12 +89,13 @@ class XPackClient(NamespacedClient):
83
89
  """
84
90
  Retrieves usage information about the installed X-Pack features.
85
91
 
86
- `<https://www.elastic.co/guide/en/elasticsearch/reference/8.12/usage-api.html>`_
92
+ `<https://www.elastic.co/guide/en/elasticsearch/reference/8.13/usage-api.html>`_
87
93
 
88
94
  :param master_timeout: Period to wait for a connection to the master node. If
89
95
  no response is received before the timeout expires, the request fails and
90
96
  returns an error.
91
97
  """
98
+ __path_parts: t.Dict[str, str] = {}
92
99
  __path = "/_xpack/usage"
93
100
  __query: t.Dict[str, t.Any] = {}
94
101
  if error_trace is not None:
@@ -103,5 +110,10 @@ class XPackClient(NamespacedClient):
103
110
  __query["pretty"] = pretty
104
111
  __headers = {"accept": "application/json"}
105
112
  return self.perform_request( # type: ignore[return-value]
106
- "GET", __path, params=__query, headers=__headers
113
+ "GET",
114
+ __path,
115
+ params=__query,
116
+ headers=__headers,
117
+ endpoint_id="xpack.usage",
118
+ path_parts=__path_parts,
107
119
  )
elasticsearch/_version.py CHANGED
@@ -15,4 +15,4 @@
15
15
  # specific language governing permissions and limitations
16
16
  # under the License.
17
17
 
18
- __versionstr__ = "8.12.1"
18
+ __versionstr__ = "8.13.1"
@@ -656,7 +656,7 @@ def scan(
656
656
  Any additional keyword arguments will be passed to the initial
657
657
  :meth:`~elasticsearch.Elasticsearch.search` call::
658
658
 
659
- scan(es,
659
+ scan(client,
660
660
  query={"query": {"match": {"title": "python"}}},
661
661
  index="orders-*",
662
662
  doc_type="books"
@@ -0,0 +1,62 @@
1
+ # Licensed to Elasticsearch B.V. under one or more contributor
2
+ # license agreements. See the NOTICE file distributed with
3
+ # this work for additional information regarding copyright
4
+ # ownership. Elasticsearch B.V. licenses this file to you under
5
+ # the Apache License, Version 2.0 (the "License"); you may
6
+ # not use this file except in compliance with the License.
7
+ # You may obtain a copy of the License at
8
+ #
9
+ # http://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing,
12
+ # software distributed under the License is distributed on an
13
+ # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14
+ # KIND, either express or implied. See the License for the
15
+ # specific language governing permissions and limitations
16
+ # under the License.
17
+
18
+ from elasticsearch.helpers.vectorstore._async.embedding_service import (
19
+ AsyncElasticsearchEmbeddings,
20
+ AsyncEmbeddingService,
21
+ )
22
+ from elasticsearch.helpers.vectorstore._async.strategies import (
23
+ AsyncBM25Strategy,
24
+ AsyncDenseVectorScriptScoreStrategy,
25
+ AsyncDenseVectorStrategy,
26
+ AsyncRetrievalStrategy,
27
+ AsyncSparseVectorStrategy,
28
+ )
29
+ from elasticsearch.helpers.vectorstore._async.vectorstore import AsyncVectorStore
30
+ from elasticsearch.helpers.vectorstore._sync.embedding_service import (
31
+ ElasticsearchEmbeddings,
32
+ EmbeddingService,
33
+ )
34
+ from elasticsearch.helpers.vectorstore._sync.strategies import (
35
+ BM25Strategy,
36
+ DenseVectorScriptScoreStrategy,
37
+ DenseVectorStrategy,
38
+ RetrievalStrategy,
39
+ SparseVectorStrategy,
40
+ )
41
+ from elasticsearch.helpers.vectorstore._sync.vectorstore import VectorStore
42
+ from elasticsearch.helpers.vectorstore._utils import DistanceMetric
43
+
44
+ __all__ = [
45
+ "AsyncBM25Strategy",
46
+ "AsyncDenseVectorScriptScoreStrategy",
47
+ "AsyncDenseVectorStrategy",
48
+ "AsyncElasticsearchEmbeddings",
49
+ "AsyncEmbeddingService",
50
+ "AsyncRetrievalStrategy",
51
+ "AsyncSparseVectorStrategy",
52
+ "AsyncVectorStore",
53
+ "BM25Strategy",
54
+ "DenseVectorScriptScoreStrategy",
55
+ "DenseVectorStrategy",
56
+ "DistanceMetric",
57
+ "ElasticsearchEmbeddings",
58
+ "EmbeddingService",
59
+ "RetrievalStrategy",
60
+ "SparseVectorStrategy",
61
+ "VectorStore",
62
+ ]
@@ -0,0 +1,16 @@
1
+ # Licensed to Elasticsearch B.V. under one or more contributor
2
+ # license agreements. See the NOTICE file distributed with
3
+ # this work for additional information regarding copyright
4
+ # ownership. Elasticsearch B.V. licenses this file to you under
5
+ # the Apache License, Version 2.0 (the "License"); you may
6
+ # not use this file except in compliance with the License.
7
+ # You may obtain a copy of the License at
8
+ #
9
+ # http://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing,
12
+ # software distributed under the License is distributed on an
13
+ # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14
+ # KIND, either express or implied. See the License for the
15
+ # specific language governing permissions and limitations
16
+ # under the License.
@@ -0,0 +1,39 @@
1
+ # Licensed to Elasticsearch B.V. under one or more contributor
2
+ # license agreements. See the NOTICE file distributed with
3
+ # this work for additional information regarding copyright
4
+ # ownership. Elasticsearch B.V. licenses this file to you under
5
+ # the Apache License, Version 2.0 (the "License"); you may
6
+ # not use this file except in compliance with the License.
7
+ # You may obtain a copy of the License at
8
+ #
9
+ # http://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing,
12
+ # software distributed under the License is distributed on an
13
+ # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14
+ # KIND, either express or implied. See the License for the
15
+ # specific language governing permissions and limitations
16
+ # under the License.
17
+
18
+ from elasticsearch import AsyncElasticsearch, BadRequestError, NotFoundError
19
+
20
+
21
+ async def model_must_be_deployed(client: AsyncElasticsearch, model_id: str) -> None:
22
+ """
23
+ :raises [NotFoundError]: if the model is neither downloaded nor deployed.
24
+ :raises [ConflictError]: if the model is downloaded but not yet deployed.
25
+ """
26
+ doc = {"text_field": f"test if the model '{model_id}' is deployed"}
27
+ try:
28
+ await client.ml.infer_trained_model(model_id=model_id, docs=[doc])
29
+ except BadRequestError:
30
+ # The model is deployed but expects a different input field name.
31
+ pass
32
+
33
+
34
+ async def model_is_deployed(client: AsyncElasticsearch, model_id: str) -> bool:
35
+ try:
36
+ await model_must_be_deployed(client, model_id)
37
+ return True
38
+ except NotFoundError:
39
+ return False
@@ -0,0 +1,89 @@
1
+ # Licensed to Elasticsearch B.V. under one or more contributor
2
+ # license agreements. See the NOTICE file distributed with
3
+ # this work for additional information regarding copyright
4
+ # ownership. Elasticsearch B.V. licenses this file to you under
5
+ # the Apache License, Version 2.0 (the "License"); you may
6
+ # not use this file except in compliance with the License.
7
+ # You may obtain a copy of the License at
8
+ #
9
+ # http://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing,
12
+ # software distributed under the License is distributed on an
13
+ # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14
+ # KIND, either express or implied. See the License for the
15
+ # specific language governing permissions and limitations
16
+ # under the License.
17
+
18
+ from abc import ABC, abstractmethod
19
+ from typing import List
20
+
21
+ from elasticsearch import AsyncElasticsearch
22
+ from elasticsearch._version import __versionstr__ as lib_version
23
+
24
+
25
+ class AsyncEmbeddingService(ABC):
26
+ @abstractmethod
27
+ async def embed_documents(self, texts: List[str]) -> List[List[float]]:
28
+ """Generate embeddings for a list of documents.
29
+
30
+ :param texts: A list of document strings to generate embeddings for.
31
+
32
+ :return: A list of embeddings, one for each document in the input.
33
+ """
34
+
35
+ @abstractmethod
36
+ async def embed_query(self, query: str) -> List[float]:
37
+ """Generate an embedding for a single query text.
38
+
39
+ :param text: The query text to generate an embedding for.
40
+
41
+ :return: The embedding for the input query text.
42
+ """
43
+
44
+
45
+ class AsyncElasticsearchEmbeddings(AsyncEmbeddingService):
46
+ """Elasticsearch as a service for embedding model inference.
47
+
48
+ You need to have an embedding model downloaded and deployed in Elasticsearch:
49
+ - https://www.elastic.co/guide/en/elasticsearch/reference/current/infer-trained-model.html
50
+ - https://www.elastic.co/guide/en/machine-learning/current/ml-nlp-deploy-models.html
51
+ """ # noqa: E501
52
+
53
+ def __init__(
54
+ self,
55
+ *,
56
+ client: AsyncElasticsearch,
57
+ model_id: str,
58
+ input_field: str = "text_field",
59
+ user_agent: str = f"elasticsearch-py-es/{lib_version}",
60
+ ):
61
+ """
62
+ :param agent_header: user agent header specific to the 3rd party integration.
63
+ Used for usage tracking in Elastic Cloud.
64
+ :param model_id: The model_id of the model deployed in the Elasticsearch cluster.
65
+ :param input_field: The name of the key for the input text field in the
66
+ document. Defaults to 'text_field'.
67
+ :param client: Elasticsearch client connection. Alternatively specify the
68
+ Elasticsearch connection with the other es_* parameters.
69
+ """
70
+ # Add integration-specific usage header for tracking usage in Elastic Cloud.
71
+ # client.options preserves existing (non-user-agent) headers.
72
+ client = client.options(headers={"User-Agent": user_agent})
73
+
74
+ self.client = client
75
+ self.model_id = model_id
76
+ self.input_field = input_field
77
+
78
+ async def embed_documents(self, texts: List[str]) -> List[List[float]]:
79
+ return await self._embedding_func(texts)
80
+
81
+ async def embed_query(self, text: str) -> List[float]:
82
+ result = await self._embedding_func([text])
83
+ return result[0]
84
+
85
+ async def _embedding_func(self, texts: List[str]) -> List[List[float]]:
86
+ response = await self.client.ml.infer_trained_model(
87
+ model_id=self.model_id, docs=[{self.input_field: text} for text in texts]
88
+ )
89
+ return [doc["predicted_value"] for doc in response["inference_results"]]