elasticsearch 9.2.1__py3-none-any.whl → 9.3.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.
Files changed (55) hide show
  1. elasticsearch/_async/client/__init__.py +44 -40
  2. elasticsearch/_async/client/async_search.py +4 -3
  3. elasticsearch/_async/client/cat.py +163 -8
  4. elasticsearch/_async/client/cluster.py +66 -34
  5. elasticsearch/_async/client/eql.py +7 -6
  6. elasticsearch/_async/client/esql.py +157 -8
  7. elasticsearch/_async/client/fleet.py +1 -1
  8. elasticsearch/_async/client/graph.py +1 -1
  9. elasticsearch/_async/client/indices.py +436 -17
  10. elasticsearch/_async/client/inference.py +299 -9
  11. elasticsearch/_async/client/ml.py +7 -3
  12. elasticsearch/_async/client/nodes.py +167 -5
  13. elasticsearch/_async/client/project.py +9 -1
  14. elasticsearch/_async/client/security.py +26 -3
  15. elasticsearch/_async/client/snapshot.py +1 -1
  16. elasticsearch/_async/client/sql.py +7 -6
  17. elasticsearch/_async/client/streams.py +0 -1
  18. elasticsearch/_async/client/text_structure.py +3 -3
  19. elasticsearch/_sync/client/__init__.py +44 -40
  20. elasticsearch/_sync/client/async_search.py +4 -3
  21. elasticsearch/_sync/client/cat.py +163 -8
  22. elasticsearch/_sync/client/cluster.py +66 -34
  23. elasticsearch/_sync/client/eql.py +7 -6
  24. elasticsearch/_sync/client/esql.py +157 -8
  25. elasticsearch/_sync/client/fleet.py +1 -1
  26. elasticsearch/_sync/client/graph.py +1 -1
  27. elasticsearch/_sync/client/indices.py +436 -17
  28. elasticsearch/_sync/client/inference.py +299 -9
  29. elasticsearch/_sync/client/ml.py +7 -3
  30. elasticsearch/_sync/client/nodes.py +167 -5
  31. elasticsearch/_sync/client/project.py +9 -1
  32. elasticsearch/_sync/client/project_routing.py +264 -0
  33. elasticsearch/_sync/client/security.py +26 -3
  34. elasticsearch/_sync/client/snapshot.py +1 -1
  35. elasticsearch/_sync/client/sql.py +7 -6
  36. elasticsearch/_sync/client/streams.py +0 -1
  37. elasticsearch/_sync/client/text_structure.py +3 -3
  38. elasticsearch/_version.py +2 -2
  39. elasticsearch/dsl/__init__.py +4 -0
  40. elasticsearch/dsl/aggs.py +6 -6
  41. elasticsearch/dsl/field.py +91 -7
  42. elasticsearch/dsl/query.py +2 -2
  43. elasticsearch/dsl/response/__init__.py +2 -0
  44. elasticsearch/dsl/types.py +66 -7
  45. elasticsearch/dsl/utils.py +11 -2
  46. elasticsearch/esql/functions.py +924 -250
  47. elasticsearch/helpers/__init__.py +2 -0
  48. elasticsearch/helpers/actions.py +21 -0
  49. elasticsearch/helpers/vectorstore/_async/vectorstore.py +3 -0
  50. elasticsearch/helpers/vectorstore/_sync/vectorstore.py +3 -0
  51. {elasticsearch-9.2.1.dist-info → elasticsearch-9.3.0.dist-info}/METADATA +2 -1
  52. {elasticsearch-9.2.1.dist-info → elasticsearch-9.3.0.dist-info}/RECORD +55 -54
  53. {elasticsearch-9.2.1.dist-info → elasticsearch-9.3.0.dist-info}/WHEEL +0 -0
  54. {elasticsearch-9.2.1.dist-info → elasticsearch-9.3.0.dist-info}/licenses/LICENSE +0 -0
  55. {elasticsearch-9.2.1.dist-info → elasticsearch-9.3.0.dist-info}/licenses/NOTICE +0 -0
@@ -1568,7 +1568,9 @@ class DenseVector(Field):
1568
1568
  self,
1569
1569
  *args: Any,
1570
1570
  dims: Union[int, "DefaultType"] = DEFAULT,
1571
- element_type: Union[Literal["bit", "byte", "float"], "DefaultType"] = DEFAULT,
1571
+ element_type: Union[
1572
+ Literal["bit", "byte", "float", "bfloat16"], "DefaultType"
1573
+ ] = DEFAULT,
1572
1574
  index: Union[bool, "DefaultType"] = DEFAULT,
1573
1575
  index_options: Union[
1574
1576
  "types.DenseVectorIndexOptions", Dict[str, Any], "DefaultType"
@@ -1616,11 +1618,33 @@ class DenseVector(Field):
1616
1618
  kwargs["multi"] = True
1617
1619
  super().__init__(*args, **kwargs)
1618
1620
 
1619
- def _deserialize(self, data: Any) -> Any:
1620
- if self._element_type == "float":
1621
- return float(data)
1622
- elif self._element_type == "byte":
1623
- return int(data)
1621
+
1622
+ class NumpyDenseVector(DenseVector):
1623
+ """A dense vector field that uses numpy arrays.
1624
+
1625
+ Accepts the same arguments as class ``DenseVector`` plus:
1626
+
1627
+ :arg dtype: The numpy data type to use for the array. If not given, numpy will select the type based on the data.
1628
+ """
1629
+
1630
+ def __init__(self, *args: Any, dtype: Optional[type] = None, **kwargs: Any):
1631
+ super().__init__(*args, **kwargs)
1632
+ self._dtype = dtype
1633
+
1634
+ def deserialize(self, data: Any) -> Any:
1635
+ if isinstance(data, list):
1636
+ import numpy as np
1637
+
1638
+ return np.array(data, dtype=self._dtype)
1639
+ return super().deserialize(data)
1640
+
1641
+ def clean(self, data: Any) -> Any:
1642
+ # this method does the same as the one in the parent classes, but it
1643
+ # avoids comparisons that do not work for numpy arrays
1644
+ if data is not None:
1645
+ data = self.deserialize(data)
1646
+ if (data is None or len(data) == 0) and self._required:
1647
+ raise ValidationException("Value required for this field.")
1624
1648
  return data
1625
1649
 
1626
1650
 
@@ -1808,6 +1832,59 @@ class DoubleRange(RangeField):
1808
1832
  super().__init__(*args, **kwargs)
1809
1833
 
1810
1834
 
1835
+ class ExponentialHistogram(Field):
1836
+ """
1837
+ :arg time_series_metric:
1838
+ :arg meta: Metadata about the field.
1839
+ :arg properties:
1840
+ :arg ignore_above:
1841
+ :arg dynamic:
1842
+ :arg fields:
1843
+ :arg synthetic_source_keep:
1844
+ """
1845
+
1846
+ name = "exponential_histogram"
1847
+ _param_defs = {
1848
+ "properties": {"type": "field", "hash": True},
1849
+ "fields": {"type": "field", "hash": True},
1850
+ }
1851
+
1852
+ def __init__(
1853
+ self,
1854
+ *args: Any,
1855
+ time_series_metric: Union[
1856
+ Literal["gauge", "counter", "summary", "histogram", "position"],
1857
+ "DefaultType",
1858
+ ] = DEFAULT,
1859
+ meta: Union[Mapping[str, str], "DefaultType"] = DEFAULT,
1860
+ properties: Union[Mapping[str, Field], "DefaultType"] = DEFAULT,
1861
+ ignore_above: Union[int, "DefaultType"] = DEFAULT,
1862
+ dynamic: Union[
1863
+ Literal["strict", "runtime", "true", "false"], bool, "DefaultType"
1864
+ ] = DEFAULT,
1865
+ fields: Union[Mapping[str, Field], "DefaultType"] = DEFAULT,
1866
+ synthetic_source_keep: Union[
1867
+ Literal["none", "arrays", "all"], "DefaultType"
1868
+ ] = DEFAULT,
1869
+ **kwargs: Any,
1870
+ ):
1871
+ if time_series_metric is not DEFAULT:
1872
+ kwargs["time_series_metric"] = time_series_metric
1873
+ if meta is not DEFAULT:
1874
+ kwargs["meta"] = meta
1875
+ if properties is not DEFAULT:
1876
+ kwargs["properties"] = properties
1877
+ if ignore_above is not DEFAULT:
1878
+ kwargs["ignore_above"] = ignore_above
1879
+ if dynamic is not DEFAULT:
1880
+ kwargs["dynamic"] = dynamic
1881
+ if fields is not DEFAULT:
1882
+ kwargs["fields"] = fields
1883
+ if synthetic_source_keep is not DEFAULT:
1884
+ kwargs["synthetic_source_keep"] = synthetic_source_keep
1885
+ super().__init__(*args, **kwargs)
1886
+
1887
+
1811
1888
  class Flattened(Field):
1812
1889
  """
1813
1890
  :arg boost:
@@ -2277,6 +2354,7 @@ class HalfFloat(Float):
2277
2354
  class Histogram(Field):
2278
2355
  """
2279
2356
  :arg ignore_malformed:
2357
+ :arg time_series_metric:
2280
2358
  :arg meta: Metadata about the field.
2281
2359
  :arg properties:
2282
2360
  :arg ignore_above:
@@ -2295,6 +2373,10 @@ class Histogram(Field):
2295
2373
  self,
2296
2374
  *args: Any,
2297
2375
  ignore_malformed: Union[bool, "DefaultType"] = DEFAULT,
2376
+ time_series_metric: Union[
2377
+ Literal["gauge", "counter", "summary", "histogram", "position"],
2378
+ "DefaultType",
2379
+ ] = DEFAULT,
2298
2380
  meta: Union[Mapping[str, str], "DefaultType"] = DEFAULT,
2299
2381
  properties: Union[Mapping[str, Field], "DefaultType"] = DEFAULT,
2300
2382
  ignore_above: Union[int, "DefaultType"] = DEFAULT,
@@ -2309,6 +2391,8 @@ class Histogram(Field):
2309
2391
  ):
2310
2392
  if ignore_malformed is not DEFAULT:
2311
2393
  kwargs["ignore_malformed"] = ignore_malformed
2394
+ if time_series_metric is not DEFAULT:
2395
+ kwargs["time_series_metric"] = time_series_metric
2312
2396
  if meta is not DEFAULT:
2313
2397
  kwargs["meta"] = meta
2314
2398
  if properties is not DEFAULT:
@@ -3892,7 +3976,7 @@ class SemanticText(Field):
3892
3976
  "types.SemanticTextIndexOptions", Dict[str, Any], "DefaultType"
3893
3977
  ] = DEFAULT,
3894
3978
  chunking_settings: Union[
3895
- "types.ChunkingSettings", Dict[str, Any], "DefaultType"
3979
+ "types.ChunkingSettings", None, Dict[str, Any], "DefaultType"
3896
3980
  ] = DEFAULT,
3897
3981
  fields: Union[Mapping[str, Field], "DefaultType"] = DEFAULT,
3898
3982
  **kwargs: Any,
@@ -1397,7 +1397,7 @@ class MoreLikeThis(Query):
1397
1397
  minimum_should_match: Union[int, str, "DefaultType"] = DEFAULT,
1398
1398
  min_term_freq: Union[int, "DefaultType"] = DEFAULT,
1399
1399
  min_word_length: Union[int, "DefaultType"] = DEFAULT,
1400
- routing: Union[str, "DefaultType"] = DEFAULT,
1400
+ routing: Union[str, Sequence[str], "DefaultType"] = DEFAULT,
1401
1401
  stop_words: Union[
1402
1402
  Literal[
1403
1403
  "_arabic_",
@@ -1719,7 +1719,7 @@ class Percolate(Query):
1719
1719
  index: Union[str, "DefaultType"] = DEFAULT,
1720
1720
  name: Union[str, "DefaultType"] = DEFAULT,
1721
1721
  preference: Union[str, "DefaultType"] = DEFAULT,
1722
- routing: Union[str, "DefaultType"] = DEFAULT,
1722
+ routing: Union[str, Sequence[str], "DefaultType"] = DEFAULT,
1723
1723
  version: Union[int, "DefaultType"] = DEFAULT,
1724
1724
  boost: Union[float, "DefaultType"] = DEFAULT,
1725
1725
  _name: Union[str, "DefaultType"] = DEFAULT,
@@ -338,6 +338,7 @@ class UpdateByQueryResponse(AttrDict[Any], Generic[_R]):
338
338
  :arg retries: The number of retries attempted by update by query.
339
339
  `bulk` is the number of bulk actions retried. `search` is the
340
340
  number of search actions retried.
341
+ :arg slices: Status of each slice if the update by query was sliced
341
342
  :arg task:
342
343
  :arg timed_out: If true, some requests timed out during the update by
343
344
  query.
@@ -366,6 +367,7 @@ class UpdateByQueryResponse(AttrDict[Any], Generic[_R]):
366
367
  deleted: int
367
368
  requests_per_second: float
368
369
  retries: "types.Retries"
370
+ slices: Sequence["types.ReindexStatus"]
369
371
  task: str
370
372
  timed_out: bool
371
373
  took: Any
@@ -400,6 +400,9 @@ class DenseVectorIndexOptions(AttrDict[Any]):
400
400
  :arg rescore_vector: The rescore vector options. This is only
401
401
  applicable to `bbq_disk`, `bbq_hnsw`, `int4_hnsw`, `int8_hnsw`,
402
402
  `bbq_flat`, `int4_flat`, and `int8_flat` index types.
403
+ :arg on_disk_rescore: `true` if vector rescoring should be done on-
404
+ disk Only applicable to `bbq_disk`, `bbq_hnsw`, `int4_hnsw`,
405
+ `int8_hnsw`
403
406
  """
404
407
 
405
408
  type: Union[
@@ -422,6 +425,7 @@ class DenseVectorIndexOptions(AttrDict[Any]):
422
425
  rescore_vector: Union[
423
426
  "DenseVectorIndexOptionsRescoreVector", Dict[str, Any], DefaultType
424
427
  ]
428
+ on_disk_rescore: Union[bool, DefaultType]
425
429
 
426
430
  def __init__(
427
431
  self,
@@ -446,6 +450,7 @@ class DenseVectorIndexOptions(AttrDict[Any]):
446
450
  rescore_vector: Union[
447
451
  "DenseVectorIndexOptionsRescoreVector", Dict[str, Any], DefaultType
448
452
  ] = DEFAULT,
453
+ on_disk_rescore: Union[bool, DefaultType] = DEFAULT,
449
454
  **kwargs: Any,
450
455
  ):
451
456
  if type is not DEFAULT:
@@ -458,6 +463,8 @@ class DenseVectorIndexOptions(AttrDict[Any]):
458
463
  kwargs["m"] = m
459
464
  if rescore_vector is not DEFAULT:
460
465
  kwargs["rescore_vector"] = rescore_vector
466
+ if on_disk_rescore is not DEFAULT:
467
+ kwargs["on_disk_rescore"] = on_disk_rescore
461
468
  super().__init__(kwargs)
462
469
 
463
470
 
@@ -602,7 +609,7 @@ class FieldLookup(AttrDict[Any]):
602
609
  id: Union[str, DefaultType]
603
610
  index: Union[str, DefaultType]
604
611
  path: Union[str, InstrumentedField, DefaultType]
605
- routing: Union[str, DefaultType]
612
+ routing: Union[str, Sequence[str], DefaultType]
606
613
 
607
614
  def __init__(
608
615
  self,
@@ -610,7 +617,7 @@ class FieldLookup(AttrDict[Any]):
610
617
  id: Union[str, DefaultType] = DEFAULT,
611
618
  index: Union[str, DefaultType] = DEFAULT,
612
619
  path: Union[str, InstrumentedField, DefaultType] = DEFAULT,
613
- routing: Union[str, DefaultType] = DEFAULT,
620
+ routing: Union[str, Sequence[str], DefaultType] = DEFAULT,
614
621
  **kwargs: Any,
615
622
  ):
616
623
  if id is not DEFAULT:
@@ -2328,7 +2335,7 @@ class LikeDocument(AttrDict[Any]):
2328
2335
  _id: Union[str, DefaultType]
2329
2336
  _index: Union[str, DefaultType]
2330
2337
  per_field_analyzer: Union[Mapping[Union[str, InstrumentedField], str], DefaultType]
2331
- routing: Union[str, DefaultType]
2338
+ routing: Union[str, Sequence[str], DefaultType]
2332
2339
  version: Union[int, DefaultType]
2333
2340
  version_type: Union[Literal["internal", "external", "external_gte"], DefaultType]
2334
2341
 
@@ -2342,7 +2349,7 @@ class LikeDocument(AttrDict[Any]):
2342
2349
  per_field_analyzer: Union[
2343
2350
  Mapping[Union[str, InstrumentedField], str], DefaultType
2344
2351
  ] = DEFAULT,
2345
- routing: Union[str, DefaultType] = DEFAULT,
2352
+ routing: Union[str, Sequence[str], DefaultType] = DEFAULT,
2346
2353
  version: Union[int, DefaultType] = DEFAULT,
2347
2354
  version_type: Union[
2348
2355
  Literal["internal", "external", "external_gte"], DefaultType
@@ -3931,7 +3938,7 @@ class TermsLookup(AttrDict[Any]):
3931
3938
  index: Union[str, DefaultType]
3932
3939
  id: Union[str, DefaultType]
3933
3940
  path: Union[str, InstrumentedField, DefaultType]
3934
- routing: Union[str, DefaultType]
3941
+ routing: Union[str, Sequence[str], DefaultType]
3935
3942
 
3936
3943
  def __init__(
3937
3944
  self,
@@ -3939,7 +3946,7 @@ class TermsLookup(AttrDict[Any]):
3939
3946
  index: Union[str, DefaultType] = DEFAULT,
3940
3947
  id: Union[str, DefaultType] = DEFAULT,
3941
3948
  path: Union[str, InstrumentedField, DefaultType] = DEFAULT,
3942
- routing: Union[str, DefaultType] = DEFAULT,
3949
+ routing: Union[str, Sequence[str], DefaultType] = DEFAULT,
3943
3950
  **kwargs: Any,
3944
3951
  ):
3945
3952
  if index is not DEFAULT:
@@ -4894,7 +4901,7 @@ class CompletionSuggestOption(AttrDict[Any]):
4894
4901
  fields: Mapping[str, Any]
4895
4902
  _id: str
4896
4903
  _index: str
4897
- _routing: str
4904
+ _routing: Union[str, Sequence[str]]
4898
4905
  _score: float
4899
4906
  _source: Any
4900
4907
  score: float
@@ -6235,6 +6242,58 @@ class RateAggregate(AttrDict[Any]):
6235
6242
  meta: Mapping[str, Any]
6236
6243
 
6237
6244
 
6245
+ class ReindexStatus(AttrDict[Any]):
6246
+ """
6247
+ :arg batches: (required) The number of scroll responses pulled back by
6248
+ the reindex.
6249
+ :arg deleted: (required) The number of documents that were
6250
+ successfully deleted.
6251
+ :arg noops: (required) The number of documents that were ignored
6252
+ because the script used for the reindex returned a `noop` value
6253
+ for `ctx.op`.
6254
+ :arg requests_per_second: (required) The number of requests per second
6255
+ effectively executed during the reindex.
6256
+ :arg retries: (required) The number of retries attempted by reindex.
6257
+ `bulk` is the number of bulk actions retried and `search` is the
6258
+ number of search actions retried.
6259
+ :arg throttled_millis: (required) Number of milliseconds the request
6260
+ slept to conform to `requests_per_second`.
6261
+ :arg throttled_until_millis: (required) This field should always be
6262
+ equal to zero in a `_reindex` response. It only has meaning when
6263
+ using the Task API, where it indicates the next time (in
6264
+ milliseconds since epoch) a throttled request will be executed
6265
+ again in order to conform to `requests_per_second`.
6266
+ :arg total: (required) The number of documents that were successfully
6267
+ processed.
6268
+ :arg version_conflicts: (required) The number of version conflicts
6269
+ that reindex hits.
6270
+ :arg slice_id: The slice ID
6271
+ :arg created: The number of documents that were successfully created.
6272
+ :arg throttled:
6273
+ :arg throttled_until:
6274
+ :arg updated: The number of documents that were successfully updated,
6275
+ for example, a document with same ID already existed prior to
6276
+ reindex updating it.
6277
+ :arg cancelled: The reason for cancellation if the slice was canceled
6278
+ """
6279
+
6280
+ batches: int
6281
+ deleted: int
6282
+ noops: int
6283
+ requests_per_second: float
6284
+ retries: "Retries"
6285
+ throttled_millis: Any
6286
+ throttled_until_millis: Any
6287
+ total: int
6288
+ version_conflicts: int
6289
+ slice_id: int
6290
+ created: int
6291
+ throttled: Any
6292
+ throttled_until: Any
6293
+ updated: int
6294
+ cancelled: str
6295
+
6296
+
6238
6297
  class Retries(AttrDict[Any]):
6239
6298
  """
6240
6299
  :arg bulk: (required) The number of bulk actions retried.
@@ -611,8 +611,17 @@ class ObjectBase(AttrDict[Any]):
611
611
  if skip_empty:
612
612
  # don't serialize empty values
613
613
  # careful not to include numeric zeros
614
- if v in ([], {}, None):
615
- continue
614
+ try:
615
+ if v in ([], {}, None):
616
+ continue
617
+ except ValueError:
618
+ # the above fails when v is a numpy array
619
+ # try using len() instead
620
+ try:
621
+ if len(v) == 0:
622
+ continue
623
+ except TypeError:
624
+ pass
616
625
 
617
626
  out[k] = v
618
627
  return out