elasticsearch 8.17.1__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.
- elasticsearch/__init__.py +2 -2
- elasticsearch/_async/client/__init__.py +2146 -859
- elasticsearch/_async/client/_base.py +0 -1
- elasticsearch/_async/client/async_search.py +44 -29
- elasticsearch/_async/client/autoscaling.py +32 -26
- elasticsearch/_async/client/cat.py +244 -169
- elasticsearch/_async/client/ccr.py +268 -128
- elasticsearch/_async/client/cluster.py +191 -164
- elasticsearch/_async/client/connector.py +212 -116
- elasticsearch/_async/client/dangling_indices.py +22 -16
- elasticsearch/_async/client/enrich.py +51 -11
- elasticsearch/_async/client/eql.py +54 -13
- elasticsearch/_async/client/esql.py +352 -4
- elasticsearch/_async/client/features.py +37 -27
- elasticsearch/_async/client/fleet.py +22 -10
- elasticsearch/_async/client/graph.py +10 -9
- elasticsearch/_async/client/ilm.py +108 -77
- elasticsearch/_async/client/indices.py +1112 -677
- elasticsearch/_async/client/inference.py +1875 -133
- elasticsearch/_async/client/ingest.py +83 -50
- elasticsearch/_async/client/license.py +90 -38
- elasticsearch/_async/client/logstash.py +20 -9
- elasticsearch/_async/client/migration.py +26 -17
- elasticsearch/_async/client/ml.py +642 -365
- elasticsearch/_async/client/monitoring.py +6 -3
- elasticsearch/_async/client/nodes.py +51 -53
- elasticsearch/_async/client/query_rules.py +59 -33
- elasticsearch/_async/client/rollup.py +124 -86
- elasticsearch/_async/client/search_application.py +60 -32
- elasticsearch/_async/client/searchable_snapshots.py +25 -12
- elasticsearch/_async/client/security.py +896 -558
- elasticsearch/_async/client/shutdown.py +34 -36
- elasticsearch/_async/client/simulate.py +22 -28
- elasticsearch/_async/client/slm.py +65 -40
- elasticsearch/_async/client/snapshot.py +190 -213
- elasticsearch/_async/client/sql.py +43 -22
- elasticsearch/_async/client/ssl.py +17 -18
- elasticsearch/_async/client/synonyms.py +58 -37
- elasticsearch/_async/client/tasks.py +77 -48
- elasticsearch/_async/client/text_structure.py +65 -56
- elasticsearch/_async/client/transform.py +124 -93
- elasticsearch/_async/client/watcher.py +116 -72
- elasticsearch/_async/client/xpack.py +18 -9
- elasticsearch/_async/helpers.py +1 -2
- elasticsearch/_sync/client/__init__.py +2146 -859
- elasticsearch/_sync/client/_base.py +0 -1
- elasticsearch/_sync/client/async_search.py +44 -29
- elasticsearch/_sync/client/autoscaling.py +32 -26
- elasticsearch/_sync/client/cat.py +244 -169
- elasticsearch/_sync/client/ccr.py +268 -128
- elasticsearch/_sync/client/cluster.py +191 -164
- elasticsearch/_sync/client/connector.py +212 -116
- elasticsearch/_sync/client/dangling_indices.py +22 -16
- elasticsearch/_sync/client/enrich.py +51 -11
- elasticsearch/_sync/client/eql.py +54 -13
- elasticsearch/_sync/client/esql.py +352 -4
- elasticsearch/_sync/client/features.py +37 -27
- elasticsearch/_sync/client/fleet.py +22 -10
- elasticsearch/_sync/client/graph.py +10 -9
- elasticsearch/_sync/client/ilm.py +108 -77
- elasticsearch/_sync/client/indices.py +1112 -677
- elasticsearch/_sync/client/inference.py +1875 -133
- elasticsearch/_sync/client/ingest.py +83 -50
- elasticsearch/_sync/client/license.py +90 -38
- elasticsearch/_sync/client/logstash.py +20 -9
- elasticsearch/_sync/client/migration.py +26 -17
- elasticsearch/_sync/client/ml.py +642 -365
- elasticsearch/_sync/client/monitoring.py +6 -3
- elasticsearch/_sync/client/nodes.py +51 -53
- elasticsearch/_sync/client/query_rules.py +59 -33
- elasticsearch/_sync/client/rollup.py +124 -86
- elasticsearch/_sync/client/search_application.py +60 -32
- elasticsearch/_sync/client/searchable_snapshots.py +25 -12
- elasticsearch/_sync/client/security.py +896 -558
- elasticsearch/_sync/client/shutdown.py +34 -36
- elasticsearch/_sync/client/simulate.py +22 -28
- elasticsearch/_sync/client/slm.py +65 -40
- elasticsearch/_sync/client/snapshot.py +190 -213
- elasticsearch/_sync/client/sql.py +43 -22
- elasticsearch/_sync/client/ssl.py +17 -18
- elasticsearch/_sync/client/synonyms.py +58 -37
- elasticsearch/_sync/client/tasks.py +77 -48
- elasticsearch/_sync/client/text_structure.py +65 -56
- elasticsearch/_sync/client/transform.py +124 -93
- elasticsearch/_sync/client/utils.py +1 -4
- elasticsearch/_sync/client/watcher.py +116 -72
- elasticsearch/_sync/client/xpack.py +18 -9
- elasticsearch/_version.py +1 -1
- elasticsearch/client.py +2 -0
- elasticsearch/dsl/__init__.py +203 -0
- elasticsearch/dsl/_async/__init__.py +16 -0
- elasticsearch/dsl/_async/document.py +522 -0
- elasticsearch/dsl/_async/faceted_search.py +50 -0
- elasticsearch/dsl/_async/index.py +639 -0
- elasticsearch/dsl/_async/mapping.py +49 -0
- elasticsearch/dsl/_async/search.py +233 -0
- elasticsearch/dsl/_async/update_by_query.py +47 -0
- elasticsearch/dsl/_sync/__init__.py +16 -0
- elasticsearch/dsl/_sync/document.py +514 -0
- elasticsearch/dsl/_sync/faceted_search.py +50 -0
- elasticsearch/dsl/_sync/index.py +597 -0
- elasticsearch/dsl/_sync/mapping.py +49 -0
- elasticsearch/dsl/_sync/search.py +226 -0
- elasticsearch/dsl/_sync/update_by_query.py +45 -0
- elasticsearch/dsl/aggs.py +3730 -0
- elasticsearch/dsl/analysis.py +341 -0
- elasticsearch/dsl/async_connections.py +37 -0
- elasticsearch/dsl/connections.py +142 -0
- elasticsearch/dsl/document.py +20 -0
- elasticsearch/dsl/document_base.py +444 -0
- elasticsearch/dsl/exceptions.py +32 -0
- elasticsearch/dsl/faceted_search.py +28 -0
- elasticsearch/dsl/faceted_search_base.py +489 -0
- elasticsearch/dsl/field.py +4254 -0
- elasticsearch/dsl/function.py +180 -0
- elasticsearch/dsl/index.py +23 -0
- elasticsearch/dsl/index_base.py +178 -0
- elasticsearch/dsl/mapping.py +19 -0
- elasticsearch/dsl/mapping_base.py +219 -0
- elasticsearch/dsl/query.py +2816 -0
- elasticsearch/dsl/response/__init__.py +388 -0
- elasticsearch/dsl/response/aggs.py +100 -0
- elasticsearch/dsl/response/hit.py +53 -0
- elasticsearch/dsl/search.py +20 -0
- elasticsearch/dsl/search_base.py +1040 -0
- elasticsearch/dsl/serializer.py +34 -0
- elasticsearch/dsl/types.py +6471 -0
- elasticsearch/dsl/update_by_query.py +19 -0
- elasticsearch/dsl/update_by_query_base.py +149 -0
- elasticsearch/dsl/utils.py +687 -0
- elasticsearch/dsl/wrappers.py +119 -0
- elasticsearch/helpers/actions.py +1 -1
- elasticsearch/helpers/vectorstore/_sync/vectorstore.py +4 -1
- {elasticsearch-8.17.1.dist-info → elasticsearch-8.18.0.dist-info}/METADATA +12 -2
- elasticsearch-8.18.0.dist-info/RECORD +161 -0
- elasticsearch-8.17.1.dist-info/RECORD +0 -119
- {elasticsearch-8.17.1.dist-info → elasticsearch-8.18.0.dist-info}/WHEEL +0 -0
- {elasticsearch-8.17.1.dist-info → elasticsearch-8.18.0.dist-info}/licenses/LICENSE +0 -0
- {elasticsearch-8.17.1.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.
|