elasticsearch 8.19.0__py3-none-any.whl → 8.19.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 (35) hide show
  1. elasticsearch/_async/client/__init__.py +12 -6
  2. elasticsearch/_async/client/cat.py +124 -10
  3. elasticsearch/_async/client/cluster.py +7 -2
  4. elasticsearch/_async/client/esql.py +16 -6
  5. elasticsearch/_async/client/indices.py +1 -1
  6. elasticsearch/_async/client/inference.py +112 -4
  7. elasticsearch/_async/client/snapshot.py +262 -112
  8. elasticsearch/_async/client/sql.py +1 -1
  9. elasticsearch/_async/client/transform.py +60 -0
  10. elasticsearch/_sync/client/__init__.py +12 -6
  11. elasticsearch/_sync/client/cat.py +124 -10
  12. elasticsearch/_sync/client/cluster.py +7 -2
  13. elasticsearch/_sync/client/esql.py +16 -6
  14. elasticsearch/_sync/client/indices.py +1 -1
  15. elasticsearch/_sync/client/inference.py +112 -4
  16. elasticsearch/_sync/client/snapshot.py +262 -112
  17. elasticsearch/_sync/client/sql.py +1 -1
  18. elasticsearch/_sync/client/transform.py +60 -0
  19. elasticsearch/_version.py +1 -1
  20. elasticsearch/dsl/_async/document.py +84 -0
  21. elasticsearch/dsl/_sync/document.py +84 -0
  22. elasticsearch/dsl/aggs.py +20 -0
  23. elasticsearch/dsl/document_base.py +43 -0
  24. elasticsearch/dsl/field.py +49 -10
  25. elasticsearch/dsl/response/aggs.py +1 -1
  26. elasticsearch/dsl/types.py +140 -11
  27. elasticsearch/dsl/utils.py +1 -1
  28. elasticsearch/esql/__init__.py +2 -1
  29. elasticsearch/esql/esql.py +85 -34
  30. elasticsearch/esql/functions.py +37 -25
  31. {elasticsearch-8.19.0.dist-info → elasticsearch-8.19.1.dist-info}/METADATA +1 -3
  32. {elasticsearch-8.19.0.dist-info → elasticsearch-8.19.1.dist-info}/RECORD +35 -35
  33. {elasticsearch-8.19.0.dist-info → elasticsearch-8.19.1.dist-info}/WHEEL +0 -0
  34. {elasticsearch-8.19.0.dist-info → elasticsearch-8.19.1.dist-info}/licenses/LICENSE +0 -0
  35. {elasticsearch-8.19.0.dist-info → elasticsearch-8.19.1.dist-info}/licenses/NOTICE +0 -0
@@ -20,6 +20,7 @@ from typing import (
20
20
  TYPE_CHECKING,
21
21
  Any,
22
22
  AsyncIterable,
23
+ AsyncIterator,
23
24
  Dict,
24
25
  List,
25
26
  Optional,
@@ -42,6 +43,7 @@ from .search import AsyncSearch
42
43
 
43
44
  if TYPE_CHECKING:
44
45
  from elasticsearch import AsyncElasticsearch
46
+ from elasticsearch.esql.esql import ESQLBase
45
47
 
46
48
 
47
49
  class AsyncIndexMeta(DocumentMeta):
@@ -520,3 +522,85 @@ class AsyncDocument(DocumentBase, metaclass=AsyncIndexMeta):
520
522
  return action
521
523
 
522
524
  return await async_bulk(es, Generate(actions), **kwargs)
525
+
526
+ @classmethod
527
+ async def esql_execute(
528
+ cls,
529
+ query: "ESQLBase",
530
+ return_additional: bool = False,
531
+ ignore_missing_fields: bool = False,
532
+ using: Optional[AsyncUsingType] = None,
533
+ **kwargs: Any,
534
+ ) -> AsyncIterator[Union[Self, Tuple[Self, Dict[str, Any]]]]:
535
+ """
536
+ Execute the given ES|QL query and return an iterator of 2-element tuples,
537
+ where the first element is an instance of this ``Document`` and the
538
+ second a dictionary with any remaining columns requested in the query.
539
+
540
+ :arg query: an ES|QL query object created with the ``esql_from()`` method.
541
+ :arg return_additional: if ``False`` (the default), this method returns
542
+ document objects. If set to ``True``, the method returns tuples with
543
+ a document in the first element and a dictionary with any additional
544
+ columns returned by the query in the second element.
545
+ :arg ignore_missing_fields: if ``False`` (the default), all the fields of
546
+ the document must be present in the query, or else an exception is
547
+ raised. Set to ``True`` to allow missing fields, which will result in
548
+ partially initialized document objects.
549
+ :arg using: connection alias to use, defaults to ``'default'``
550
+ :arg kwargs: additional options for the ``client.esql.query()`` function.
551
+ """
552
+ es = cls._get_connection(using)
553
+ response = await es.esql.query(query=str(query), **kwargs)
554
+ query_columns = [col["name"] for col in response.body.get("columns", [])]
555
+
556
+ # Here we get the list of columns defined in the document, which are the
557
+ # columns that we will take from each result to assemble the document
558
+ # object.
559
+ # When `for_esql=False` is passed below by default, the list will include
560
+ # nested fields, which ES|QL does not return, causing an error. When passing
561
+ # `ignore_missing_fields=True` the list will be generated with
562
+ # `for_esql=True`, so the error will not occur, but the documents will
563
+ # not have any Nested objects in them.
564
+ doc_fields = set(cls._get_field_names(for_esql=ignore_missing_fields))
565
+ if not ignore_missing_fields and not doc_fields.issubset(set(query_columns)):
566
+ raise ValueError(
567
+ f"Not all fields of {cls.__name__} were returned by the query. "
568
+ "Make sure your document does not use Nested fields, which are "
569
+ "currently not supported in ES|QL. To force the query to be "
570
+ "evaluated in spite of the missing fields, pass set the "
571
+ "ignore_missing_fields=True option in the esql_execute() call."
572
+ )
573
+ non_doc_fields: set[str] = set(query_columns) - doc_fields - {"_id"}
574
+ index_id = query_columns.index("_id")
575
+
576
+ results = response.body.get("values", [])
577
+ for column_values in results:
578
+ # create a dictionary with all the document fields, expanding the
579
+ # dot notation returned by ES|QL into the recursive dictionaries
580
+ # used by Document.from_dict()
581
+ doc_dict: Dict[str, Any] = {}
582
+ for col, val in zip(query_columns, column_values):
583
+ if col in doc_fields:
584
+ cols = col.split(".")
585
+ d = doc_dict
586
+ for c in cols[:-1]:
587
+ if c not in d:
588
+ d[c] = {}
589
+ d = d[c]
590
+ d[cols[-1]] = val
591
+
592
+ # create the document instance
593
+ obj = cls(meta={"_id": column_values[index_id]})
594
+ obj._from_dict(doc_dict)
595
+
596
+ if return_additional:
597
+ # build a dict with any other values included in the response
598
+ other = {
599
+ col: val
600
+ for col, val in zip(query_columns, column_values)
601
+ if col in non_doc_fields
602
+ }
603
+
604
+ yield obj, other
605
+ else:
606
+ yield obj
@@ -21,6 +21,7 @@ from typing import (
21
21
  Any,
22
22
  Dict,
23
23
  Iterable,
24
+ Iterator,
24
25
  List,
25
26
  Optional,
26
27
  Tuple,
@@ -42,6 +43,7 @@ from .search import Search
42
43
 
43
44
  if TYPE_CHECKING:
44
45
  from elasticsearch import Elasticsearch
46
+ from elasticsearch.esql.esql import ESQLBase
45
47
 
46
48
 
47
49
  class IndexMeta(DocumentMeta):
@@ -512,3 +514,85 @@ class Document(DocumentBase, metaclass=IndexMeta):
512
514
  return action
513
515
 
514
516
  return bulk(es, Generate(actions), **kwargs)
517
+
518
+ @classmethod
519
+ def esql_execute(
520
+ cls,
521
+ query: "ESQLBase",
522
+ return_additional: bool = False,
523
+ ignore_missing_fields: bool = False,
524
+ using: Optional[UsingType] = None,
525
+ **kwargs: Any,
526
+ ) -> Iterator[Union[Self, Tuple[Self, Dict[str, Any]]]]:
527
+ """
528
+ Execute the given ES|QL query and return an iterator of 2-element tuples,
529
+ where the first element is an instance of this ``Document`` and the
530
+ second a dictionary with any remaining columns requested in the query.
531
+
532
+ :arg query: an ES|QL query object created with the ``esql_from()`` method.
533
+ :arg return_additional: if ``False`` (the default), this method returns
534
+ document objects. If set to ``True``, the method returns tuples with
535
+ a document in the first element and a dictionary with any additional
536
+ columns returned by the query in the second element.
537
+ :arg ignore_missing_fields: if ``False`` (the default), all the fields of
538
+ the document must be present in the query, or else an exception is
539
+ raised. Set to ``True`` to allow missing fields, which will result in
540
+ partially initialized document objects.
541
+ :arg using: connection alias to use, defaults to ``'default'``
542
+ :arg kwargs: additional options for the ``client.esql.query()`` function.
543
+ """
544
+ es = cls._get_connection(using)
545
+ response = es.esql.query(query=str(query), **kwargs)
546
+ query_columns = [col["name"] for col in response.body.get("columns", [])]
547
+
548
+ # Here we get the list of columns defined in the document, which are the
549
+ # columns that we will take from each result to assemble the document
550
+ # object.
551
+ # When `for_esql=False` is passed below by default, the list will include
552
+ # nested fields, which ES|QL does not return, causing an error. When passing
553
+ # `ignore_missing_fields=True` the list will be generated with
554
+ # `for_esql=True`, so the error will not occur, but the documents will
555
+ # not have any Nested objects in them.
556
+ doc_fields = set(cls._get_field_names(for_esql=ignore_missing_fields))
557
+ if not ignore_missing_fields and not doc_fields.issubset(set(query_columns)):
558
+ raise ValueError(
559
+ f"Not all fields of {cls.__name__} were returned by the query. "
560
+ "Make sure your document does not use Nested fields, which are "
561
+ "currently not supported in ES|QL. To force the query to be "
562
+ "evaluated in spite of the missing fields, pass set the "
563
+ "ignore_missing_fields=True option in the esql_execute() call."
564
+ )
565
+ non_doc_fields: set[str] = set(query_columns) - doc_fields - {"_id"}
566
+ index_id = query_columns.index("_id")
567
+
568
+ results = response.body.get("values", [])
569
+ for column_values in results:
570
+ # create a dictionary with all the document fields, expanding the
571
+ # dot notation returned by ES|QL into the recursive dictionaries
572
+ # used by Document.from_dict()
573
+ doc_dict: Dict[str, Any] = {}
574
+ for col, val in zip(query_columns, column_values):
575
+ if col in doc_fields:
576
+ cols = col.split(".")
577
+ d = doc_dict
578
+ for c in cols[:-1]:
579
+ if c not in d:
580
+ d[c] = {}
581
+ d = d[c]
582
+ d[cols[-1]] = val
583
+
584
+ # create the document instance
585
+ obj = cls(meta={"_id": column_values[index_id]})
586
+ obj._from_dict(doc_dict)
587
+
588
+ if return_additional:
589
+ # build a dict with any other values included in the response
590
+ other = {
591
+ col: val
592
+ for col, val in zip(query_columns, column_values)
593
+ if col in non_doc_fields
594
+ }
595
+
596
+ yield obj, other
597
+ else:
598
+ yield obj
elasticsearch/dsl/aggs.py CHANGED
@@ -372,6 +372,12 @@ class Boxplot(Agg[_R]):
372
372
  :arg compression: Limits the maximum number of nodes used by the
373
373
  underlying TDigest algorithm to `20 * compression`, enabling
374
374
  control of memory usage and approximation error.
375
+ :arg execution_hint: The default implementation of TDigest is
376
+ optimized for performance, scaling to millions or even billions of
377
+ sample values while maintaining acceptable accuracy levels (close
378
+ to 1% relative error for millions of samples in some cases). To
379
+ use an implementation optimized for accuracy, set this parameter
380
+ to high_accuracy instead. Defaults to `default` if omitted.
375
381
  :arg field: The field on which to run the aggregation.
376
382
  :arg missing: The value to apply to documents that do not have a
377
383
  value. By default, documents without a value are ignored.
@@ -384,6 +390,9 @@ class Boxplot(Agg[_R]):
384
390
  self,
385
391
  *,
386
392
  compression: Union[float, "DefaultType"] = DEFAULT,
393
+ execution_hint: Union[
394
+ Literal["default", "high_accuracy"], "DefaultType"
395
+ ] = DEFAULT,
387
396
  field: Union[str, "InstrumentedField", "DefaultType"] = DEFAULT,
388
397
  missing: Union[str, int, float, bool, "DefaultType"] = DEFAULT,
389
398
  script: Union["types.Script", Dict[str, Any], "DefaultType"] = DEFAULT,
@@ -391,6 +400,7 @@ class Boxplot(Agg[_R]):
391
400
  ):
392
401
  super().__init__(
393
402
  compression=compression,
403
+ execution_hint=execution_hint,
394
404
  field=field,
395
405
  missing=missing,
396
406
  script=script,
@@ -1897,6 +1907,12 @@ class MedianAbsoluteDeviation(Agg[_R]):
1897
1907
  underlying TDigest algorithm to `20 * compression`, enabling
1898
1908
  control of memory usage and approximation error. Defaults to
1899
1909
  `1000` if omitted.
1910
+ :arg execution_hint: The default implementation of TDigest is
1911
+ optimized for performance, scaling to millions or even billions of
1912
+ sample values while maintaining acceptable accuracy levels (close
1913
+ to 1% relative error for millions of samples in some cases). To
1914
+ use an implementation optimized for accuracy, set this parameter
1915
+ to high_accuracy instead. Defaults to `default` if omitted.
1900
1916
  :arg format:
1901
1917
  :arg field: The field on which to run the aggregation.
1902
1918
  :arg missing: The value to apply to documents that do not have a
@@ -1910,6 +1926,9 @@ class MedianAbsoluteDeviation(Agg[_R]):
1910
1926
  self,
1911
1927
  *,
1912
1928
  compression: Union[float, "DefaultType"] = DEFAULT,
1929
+ execution_hint: Union[
1930
+ Literal["default", "high_accuracy"], "DefaultType"
1931
+ ] = DEFAULT,
1913
1932
  format: Union[str, "DefaultType"] = DEFAULT,
1914
1933
  field: Union[str, "InstrumentedField", "DefaultType"] = DEFAULT,
1915
1934
  missing: Union[str, int, float, bool, "DefaultType"] = DEFAULT,
@@ -1918,6 +1937,7 @@ class MedianAbsoluteDeviation(Agg[_R]):
1918
1937
  ):
1919
1938
  super().__init__(
1920
1939
  compression=compression,
1940
+ execution_hint=execution_hint,
1921
1941
  format=format,
1922
1942
  field=field,
1923
1943
  missing=missing,
@@ -28,6 +28,7 @@ from typing import (
28
28
  List,
29
29
  Optional,
30
30
  Tuple,
31
+ Type,
31
32
  TypeVar,
32
33
  Union,
33
34
  get_args,
@@ -49,6 +50,7 @@ from .utils import DOC_META_FIELDS, ObjectBase
49
50
  if TYPE_CHECKING:
50
51
  from elastic_transport import ObjectApiResponse
51
52
 
53
+ from ..esql.esql import ESQLBase
52
54
  from .index_base import IndexBase
53
55
 
54
56
 
@@ -602,3 +604,44 @@ class DocumentBase(ObjectBase):
602
604
 
603
605
  meta["_source"] = d
604
606
  return meta
607
+
608
+ @classmethod
609
+ def _get_field_names(
610
+ cls, for_esql: bool = False, nested_class: Optional[Type[InnerDoc]] = None
611
+ ) -> List[str]:
612
+ """Return the list of field names used by this document.
613
+ If the document has nested objects, their fields are reported using dot
614
+ notation. If the ``for_esql`` argument is set to ``True``, the list omits
615
+ nested fields, which are currently unsupported in ES|QL.
616
+ """
617
+ fields = []
618
+ class_ = nested_class or cls
619
+ for field_name in class_._doc_type.mapping:
620
+ field = class_._doc_type.mapping[field_name]
621
+ if isinstance(field, Object):
622
+ if for_esql and isinstance(field, Nested):
623
+ # ES|QL does not recognize Nested fields at this time
624
+ continue
625
+ sub_fields = cls._get_field_names(
626
+ for_esql=for_esql, nested_class=field._doc_class
627
+ )
628
+ for sub_field in sub_fields:
629
+ fields.append(f"{field_name}.{sub_field}")
630
+ else:
631
+ fields.append(field_name)
632
+ return fields
633
+
634
+ @classmethod
635
+ def esql_from(cls) -> "ESQLBase":
636
+ """Return a base ES|QL query for instances of this document class.
637
+
638
+ The returned query is initialized with ``FROM`` and ``KEEP`` statements,
639
+ and can be completed as desired.
640
+ """
641
+ from ..esql import ESQL # here to avoid circular imports
642
+
643
+ return (
644
+ ESQL.from_(cls)
645
+ .metadata("_id")
646
+ .keep("_id", *tuple(cls._get_field_names(for_esql=True)))
647
+ )
@@ -119,9 +119,16 @@ class Field(DslBase):
119
119
  def __getitem__(self, subfield: str) -> "Field":
120
120
  return cast(Field, self._params.get("fields", {})[subfield])
121
121
 
122
- def _serialize(self, data: Any) -> Any:
122
+ def _serialize(self, data: Any, skip_empty: bool) -> Any:
123
123
  return data
124
124
 
125
+ def _safe_serialize(self, data: Any, skip_empty: bool) -> Any:
126
+ try:
127
+ return self._serialize(data, skip_empty)
128
+ except TypeError:
129
+ # older method signature, without skip_empty
130
+ return self._serialize(data) # type: ignore[call-arg]
131
+
125
132
  def _deserialize(self, data: Any) -> Any:
126
133
  return data
127
134
 
@@ -133,10 +140,16 @@ class Field(DslBase):
133
140
  return AttrList([])
134
141
  return self._empty()
135
142
 
136
- def serialize(self, data: Any) -> Any:
143
+ def serialize(self, data: Any, skip_empty: bool = True) -> Any:
137
144
  if isinstance(data, (list, AttrList, tuple)):
138
- return list(map(self._serialize, cast(Iterable[Any], data)))
139
- return self._serialize(data)
145
+ return list(
146
+ map(
147
+ self._safe_serialize,
148
+ cast(Iterable[Any], data),
149
+ [skip_empty] * len(data),
150
+ )
151
+ )
152
+ return self._safe_serialize(data, skip_empty)
140
153
 
141
154
  def deserialize(self, data: Any) -> Any:
142
155
  if isinstance(data, (list, AttrList, tuple)):
@@ -186,7 +199,7 @@ class RangeField(Field):
186
199
  data = {k: self._core_field.deserialize(v) for k, v in data.items()} # type: ignore[union-attr]
187
200
  return Range(data)
188
201
 
189
- def _serialize(self, data: Any) -> Optional[Dict[str, Any]]:
202
+ def _serialize(self, data: Any, skip_empty: bool) -> Optional[Dict[str, Any]]:
190
203
  if data is None:
191
204
  return None
192
205
  if not isinstance(data, collections.abc.Mapping):
@@ -550,7 +563,7 @@ class Object(Field):
550
563
  return self._wrap(data)
551
564
 
552
565
  def _serialize(
553
- self, data: Optional[Union[Dict[str, Any], "InnerDoc"]]
566
+ self, data: Optional[Union[Dict[str, Any], "InnerDoc"]], skip_empty: bool
554
567
  ) -> Optional[Dict[str, Any]]:
555
568
  if data is None:
556
569
  return None
@@ -559,7 +572,7 @@ class Object(Field):
559
572
  if isinstance(data, collections.abc.Mapping):
560
573
  return data
561
574
 
562
- return data.to_dict()
575
+ return data.to_dict(skip_empty=skip_empty)
563
576
 
564
577
  def clean(self, data: Any) -> Any:
565
578
  data = super().clean(data)
@@ -768,7 +781,7 @@ class Binary(Field):
768
781
  def _deserialize(self, data: Any) -> bytes:
769
782
  return base64.b64decode(data)
770
783
 
771
- def _serialize(self, data: Any) -> Optional[str]:
784
+ def _serialize(self, data: Any, skip_empty: bool) -> Optional[str]:
772
785
  if data is None:
773
786
  return None
774
787
  return base64.b64encode(data).decode()
@@ -2619,7 +2632,7 @@ class Ip(Field):
2619
2632
  # the ipaddress library for pypy only accepts unicode.
2620
2633
  return ipaddress.ip_address(unicode(data))
2621
2634
 
2622
- def _serialize(self, data: Any) -> Optional[str]:
2635
+ def _serialize(self, data: Any, skip_empty: bool) -> Optional[str]:
2623
2636
  if data is None:
2624
2637
  return None
2625
2638
  return str(data)
@@ -3367,7 +3380,7 @@ class Percolator(Field):
3367
3380
  def _deserialize(self, data: Any) -> "Query":
3368
3381
  return Q(data) # type: ignore[no-any-return]
3369
3382
 
3370
- def _serialize(self, data: Any) -> Optional[Dict[str, Any]]:
3383
+ def _serialize(self, data: Any, skip_empty: bool) -> Optional[Dict[str, Any]]:
3371
3384
  if data is None:
3372
3385
  return None
3373
3386
  return data.to_dict() # type: ignore[no-any-return]
@@ -3849,6 +3862,14 @@ class SemanticText(Field):
3849
3862
  by using the Update mapping API. Use the Create inference API to
3850
3863
  create the endpoint. If not specified, the inference endpoint
3851
3864
  defined by inference_id will be used at both index and query time.
3865
+ :arg index_options: Settings for index_options that override any
3866
+ defaults used by semantic_text, for example specific quantization
3867
+ settings.
3868
+ :arg chunking_settings: Settings for chunking text into smaller
3869
+ passages. If specified, these will override the chunking settings
3870
+ sent in the inference endpoint associated with inference_id. If
3871
+ chunking settings are updated, they will not be applied to
3872
+ existing documents until they are reindexed.
3852
3873
  """
3853
3874
 
3854
3875
  name = "semantic_text"
@@ -3859,6 +3880,12 @@ class SemanticText(Field):
3859
3880
  meta: Union[Mapping[str, str], "DefaultType"] = DEFAULT,
3860
3881
  inference_id: Union[str, "DefaultType"] = DEFAULT,
3861
3882
  search_inference_id: Union[str, "DefaultType"] = DEFAULT,
3883
+ index_options: Union[
3884
+ "types.SemanticTextIndexOptions", Dict[str, Any], "DefaultType"
3885
+ ] = DEFAULT,
3886
+ chunking_settings: Union[
3887
+ "types.ChunkingSettings", Dict[str, Any], "DefaultType"
3888
+ ] = DEFAULT,
3862
3889
  **kwargs: Any,
3863
3890
  ):
3864
3891
  if meta is not DEFAULT:
@@ -3867,6 +3894,10 @@ class SemanticText(Field):
3867
3894
  kwargs["inference_id"] = inference_id
3868
3895
  if search_inference_id is not DEFAULT:
3869
3896
  kwargs["search_inference_id"] = search_inference_id
3897
+ if index_options is not DEFAULT:
3898
+ kwargs["index_options"] = index_options
3899
+ if chunking_settings is not DEFAULT:
3900
+ kwargs["chunking_settings"] = chunking_settings
3870
3901
  super().__init__(*args, **kwargs)
3871
3902
 
3872
3903
 
@@ -4063,6 +4094,9 @@ class Short(Integer):
4063
4094
  class SparseVector(Field):
4064
4095
  """
4065
4096
  :arg store:
4097
+ :arg index_options: Additional index options for the sparse vector
4098
+ field that controls the token pruning behavior of the sparse
4099
+ vector field.
4066
4100
  :arg meta: Metadata about the field.
4067
4101
  :arg properties:
4068
4102
  :arg ignore_above:
@@ -4081,6 +4115,9 @@ class SparseVector(Field):
4081
4115
  self,
4082
4116
  *args: Any,
4083
4117
  store: Union[bool, "DefaultType"] = DEFAULT,
4118
+ index_options: Union[
4119
+ "types.SparseVectorIndexOptions", Dict[str, Any], "DefaultType"
4120
+ ] = DEFAULT,
4084
4121
  meta: Union[Mapping[str, str], "DefaultType"] = DEFAULT,
4085
4122
  properties: Union[Mapping[str, Field], "DefaultType"] = DEFAULT,
4086
4123
  ignore_above: Union[int, "DefaultType"] = DEFAULT,
@@ -4095,6 +4132,8 @@ class SparseVector(Field):
4095
4132
  ):
4096
4133
  if store is not DEFAULT:
4097
4134
  kwargs["store"] = store
4135
+ if index_options is not DEFAULT:
4136
+ kwargs["index_options"] = index_options
4098
4137
  if meta is not DEFAULT:
4099
4138
  kwargs["meta"] = meta
4100
4139
  if properties is not DEFAULT:
@@ -63,7 +63,7 @@ class BucketData(AggResponse[_R]):
63
63
  )
64
64
 
65
65
  def __iter__(self) -> Iterator["Agg"]: # type: ignore[override]
66
- return iter(self.buckets) # type: ignore[arg-type]
66
+ return iter(self.buckets)
67
67
 
68
68
  def __len__(self) -> int:
69
69
  return len(self.buckets)