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