elasticsearch 9.0.2__py3-none-any.whl → 9.0.4__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 (61) hide show
  1. elasticsearch/_async/client/__init__.py +59 -202
  2. elasticsearch/_async/client/cat.py +1011 -59
  3. elasticsearch/_async/client/cluster.py +14 -4
  4. elasticsearch/_async/client/eql.py +10 -2
  5. elasticsearch/_async/client/esql.py +33 -10
  6. elasticsearch/_async/client/indices.py +88 -44
  7. elasticsearch/_async/client/inference.py +108 -3
  8. elasticsearch/_async/client/ingest.py +0 -7
  9. elasticsearch/_async/client/license.py +4 -4
  10. elasticsearch/_async/client/ml.py +6 -17
  11. elasticsearch/_async/client/monitoring.py +1 -1
  12. elasticsearch/_async/client/rollup.py +1 -22
  13. elasticsearch/_async/client/security.py +11 -17
  14. elasticsearch/_async/client/snapshot.py +6 -0
  15. elasticsearch/_async/client/sql.py +1 -1
  16. elasticsearch/_async/client/synonyms.py +1 -0
  17. elasticsearch/_async/client/transform.py +60 -0
  18. elasticsearch/_async/client/watcher.py +4 -2
  19. elasticsearch/_sync/client/__init__.py +59 -202
  20. elasticsearch/_sync/client/cat.py +1011 -59
  21. elasticsearch/_sync/client/cluster.py +14 -4
  22. elasticsearch/_sync/client/eql.py +10 -2
  23. elasticsearch/_sync/client/esql.py +33 -10
  24. elasticsearch/_sync/client/indices.py +88 -44
  25. elasticsearch/_sync/client/inference.py +108 -3
  26. elasticsearch/_sync/client/ingest.py +0 -7
  27. elasticsearch/_sync/client/license.py +4 -4
  28. elasticsearch/_sync/client/ml.py +6 -17
  29. elasticsearch/_sync/client/monitoring.py +1 -1
  30. elasticsearch/_sync/client/rollup.py +1 -22
  31. elasticsearch/_sync/client/security.py +11 -17
  32. elasticsearch/_sync/client/snapshot.py +6 -0
  33. elasticsearch/_sync/client/sql.py +1 -1
  34. elasticsearch/_sync/client/synonyms.py +1 -0
  35. elasticsearch/_sync/client/transform.py +60 -0
  36. elasticsearch/_sync/client/watcher.py +4 -2
  37. elasticsearch/_version.py +1 -1
  38. elasticsearch/compat.py +5 -0
  39. elasticsearch/dsl/__init__.py +2 -1
  40. elasticsearch/dsl/_async/document.py +84 -0
  41. elasticsearch/dsl/_sync/document.py +84 -0
  42. elasticsearch/dsl/document_base.py +219 -16
  43. elasticsearch/dsl/field.py +245 -57
  44. elasticsearch/dsl/query.py +7 -4
  45. elasticsearch/dsl/response/aggs.py +1 -1
  46. elasticsearch/dsl/types.py +125 -88
  47. elasticsearch/dsl/utils.py +2 -2
  48. elasticsearch/{dsl/_sync/_sync_check → esql}/__init__.py +3 -0
  49. elasticsearch/esql/esql.py +1156 -0
  50. elasticsearch/esql/functions.py +1750 -0
  51. {elasticsearch-9.0.2.dist-info → elasticsearch-9.0.4.dist-info}/METADATA +1 -3
  52. {elasticsearch-9.0.2.dist-info → elasticsearch-9.0.4.dist-info}/RECORD +55 -59
  53. elasticsearch/dsl/_sync/_sync_check/document.py +0 -514
  54. elasticsearch/dsl/_sync/_sync_check/faceted_search.py +0 -50
  55. elasticsearch/dsl/_sync/_sync_check/index.py +0 -597
  56. elasticsearch/dsl/_sync/_sync_check/mapping.py +0 -49
  57. elasticsearch/dsl/_sync/_sync_check/search.py +0 -230
  58. elasticsearch/dsl/_sync/_sync_check/update_by_query.py +0 -45
  59. {elasticsearch-9.0.2.dist-info → elasticsearch-9.0.4.dist-info}/WHEEL +0 -0
  60. {elasticsearch-9.0.2.dist-info → elasticsearch-9.0.4.dist-info}/licenses/LICENSE +0 -0
  61. {elasticsearch-9.0.2.dist-info → elasticsearch-9.0.4.dist-info}/licenses/NOTICE +0 -0
@@ -1,230 +0,0 @@
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
- import contextlib
19
- from typing import (
20
- TYPE_CHECKING,
21
- Any,
22
- Dict,
23
- Iterator,
24
- List,
25
- Optional,
26
- cast,
27
- )
28
-
29
- from typing_extensions import Self
30
-
31
- from elasticsearch.exceptions import ApiError
32
- from elasticsearch.helpers import scan
33
-
34
- from ..connections import get_connection
35
- from ..response import Response
36
- from ..search_base import MultiSearchBase, SearchBase
37
- from ..utils import _R, AttrDict, UsingType
38
-
39
-
40
- class Search(SearchBase[_R]):
41
- _using: UsingType
42
-
43
- def __iter__(self) -> Iterator[_R]:
44
- """
45
- Iterate over the hits.
46
- """
47
-
48
- class ResultsIterator(Iterator[_R]):
49
- def __init__(self, search: Search[_R]):
50
- self.search = search
51
- self.iterator: Optional[Iterator[_R]] = None
52
-
53
- def __next__(self) -> _R:
54
- if self.iterator is None:
55
- self.iterator = iter(self.search.execute())
56
- try:
57
- return next(self.iterator)
58
- except StopIteration:
59
- raise StopIteration()
60
-
61
- return ResultsIterator(self)
62
-
63
- def count(self) -> int:
64
- """
65
- Return the number of hits matching the query and filters. Note that
66
- only the actual number is returned.
67
- """
68
- if hasattr(self, "_response") and self._response.hits.total.relation == "eq": # type: ignore[attr-defined]
69
- return cast(int, self._response.hits.total.value) # type: ignore[attr-defined]
70
-
71
- es = get_connection(self._using)
72
-
73
- d = self.to_dict(count=True)
74
- # TODO: failed shards detection
75
- resp = es.count(
76
- index=self._index,
77
- query=cast(Optional[Dict[str, Any]], d.get("query", None)),
78
- **self._params,
79
- )
80
-
81
- return cast(int, resp["count"])
82
-
83
- def execute(self, ignore_cache: bool = False) -> Response[_R]:
84
- """
85
- Execute the search and return an instance of ``Response`` wrapping all
86
- the data.
87
-
88
- :arg ignore_cache: if set to ``True``, consecutive calls will hit
89
- ES, while cached result will be ignored. Defaults to `False`
90
- """
91
- if ignore_cache or not hasattr(self, "_response"):
92
- es = get_connection(self._using)
93
-
94
- self._response = self._response_class(
95
- self,
96
- (
97
- es.search(index=self._index, body=self.to_dict(), **self._params)
98
- ).body,
99
- )
100
- return self._response
101
-
102
- def scan(self) -> Iterator[_R]:
103
- """
104
- Turn the search into a scan search and return a generator that will
105
- iterate over all the documents matching the query.
106
-
107
- Use the ``params`` method to specify any additional arguments you wish to
108
- pass to the underlying ``scan`` helper from ``elasticsearch-py`` -
109
- https://elasticsearch-py.readthedocs.io/en/latest/helpers.html#scan
110
-
111
- The ``iterate()`` method should be preferred, as it provides similar
112
- functionality using an Elasticsearch point in time.
113
- """
114
- es = get_connection(self._using)
115
-
116
- for hit in scan(es, query=self.to_dict(), index=self._index, **self._params):
117
- yield self._get_result(cast(AttrDict[Any], hit))
118
-
119
- def delete(self) -> AttrDict[Any]:
120
- """
121
- ``delete()`` executes the query by delegating to ``delete_by_query()``.
122
-
123
- Use the ``params`` method to specify any additional arguments you wish to
124
- pass to the underlying ``delete_by_query`` helper from ``elasticsearch-py`` -
125
- https://elasticsearch-py.readthedocs.io/en/latest/api/elasticsearch.html#elasticsearch.Elasticsearch.delete_by_query
126
- """
127
-
128
- es = get_connection(self._using)
129
- assert self._index is not None
130
-
131
- return AttrDict(
132
- cast(
133
- Dict[str, Any],
134
- es.delete_by_query(
135
- index=self._index, body=self.to_dict(), **self._params
136
- ),
137
- )
138
- )
139
-
140
- @contextlib.contextmanager
141
- def point_in_time(self, keep_alive: str = "1m") -> Iterator[Self]:
142
- """
143
- Open a point in time (pit) that can be used across several searches.
144
-
145
- This method implements a context manager that returns a search object
146
- configured to operate within the created pit.
147
-
148
- :arg keep_alive: the time to live for the point in time, renewed with each search request
149
- """
150
- es = get_connection(self._using)
151
-
152
- pit = es.open_point_in_time(index=self._index or "*", keep_alive=keep_alive)
153
- search = self.index().extra(pit={"id": pit["id"], "keep_alive": keep_alive})
154
- if not search._sort:
155
- search = search.sort("_shard_doc")
156
- yield search
157
- es.close_point_in_time(id=pit["id"])
158
-
159
- def iterate(self, keep_alive: str = "1m") -> Iterator[_R]:
160
- """
161
- Return a generator that iterates over all the documents matching the query.
162
-
163
- This method uses a point in time to provide consistent results even when
164
- the index is changing. It should be preferred over ``scan()``.
165
-
166
- :arg keep_alive: the time to live for the point in time, renewed with each new search request
167
- """
168
- with self.point_in_time(keep_alive=keep_alive) as s:
169
- while True:
170
- r = s.execute()
171
- for hit in r:
172
- yield hit
173
- if len(r.hits) == 0:
174
- break
175
- s = s.search_after()
176
-
177
-
178
- class MultiSearch(MultiSearchBase[_R]):
179
- """
180
- Combine multiple :class:`~elasticsearch.dsl.Search` objects into a single
181
- request.
182
- """
183
-
184
- _using: UsingType
185
-
186
- if TYPE_CHECKING:
187
-
188
- def add(self, search: Search[_R]) -> Self: ... # type: ignore[override]
189
-
190
- def execute(
191
- self, ignore_cache: bool = False, raise_on_error: bool = True
192
- ) -> List[Response[_R]]:
193
- """
194
- Execute the multi search request and return a list of search results.
195
- """
196
- if ignore_cache or not hasattr(self, "_response"):
197
- es = get_connection(self._using)
198
-
199
- responses = es.msearch(
200
- index=self._index, body=self.to_dict(), **self._params
201
- )
202
-
203
- out: List[Response[_R]] = []
204
- for s, r in zip(self._searches, responses["responses"]):
205
- if r.get("error", False):
206
- if raise_on_error:
207
- raise ApiError("N/A", meta=responses.meta, body=r)
208
- r = None
209
- else:
210
- r = Response(s, r)
211
- out.append(r)
212
-
213
- self._response = out
214
-
215
- return self._response
216
-
217
-
218
- class EmptySearch(Search[_R]):
219
- def count(self) -> int:
220
- return 0
221
-
222
- def execute(self, ignore_cache: bool = False) -> Response[_R]:
223
- return self._response_class(self, {"hits": {"total": 0, "hits": []}})
224
-
225
- def scan(self) -> Iterator[_R]:
226
- return
227
- yield # a bit strange, but this forces an empty generator function
228
-
229
- def delete(self) -> AttrDict[Any]:
230
- return AttrDict[Any]({})
@@ -1,45 +0,0 @@
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 typing import TYPE_CHECKING
19
-
20
- from ..connections import get_connection
21
- from ..update_by_query_base import UpdateByQueryBase
22
- from ..utils import _R, UsingType
23
-
24
- if TYPE_CHECKING:
25
- from ..response import UpdateByQueryResponse
26
-
27
-
28
- class UpdateByQuery(UpdateByQueryBase[_R]):
29
- _using: UsingType
30
-
31
- def execute(self) -> "UpdateByQueryResponse[_R]":
32
- """
33
- Execute the search and return an instance of ``Response`` wrapping all
34
- the data.
35
- """
36
- es = get_connection(self._using)
37
- assert self._index is not None
38
-
39
- self._response = self._response_class(
40
- self,
41
- (
42
- es.update_by_query(index=self._index, **self.to_dict(), **self._params)
43
- ).body,
44
- )
45
- return self._response