elasticsearch9 9.0.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 (160) hide show
  1. elasticsearch9/__init__.py +98 -0
  2. elasticsearch9/_async/__init__.py +16 -0
  3. elasticsearch9/_async/client/__init__.py +6531 -0
  4. elasticsearch9/_async/client/_base.py +430 -0
  5. elasticsearch9/_async/client/async_search.py +637 -0
  6. elasticsearch9/_async/client/autoscaling.py +252 -0
  7. elasticsearch9/_async/client/cat.py +2995 -0
  8. elasticsearch9/_async/client/ccr.py +1043 -0
  9. elasticsearch9/_async/client/cluster.py +1223 -0
  10. elasticsearch9/_async/client/connector.py +1978 -0
  11. elasticsearch9/_async/client/dangling_indices.py +192 -0
  12. elasticsearch9/_async/client/enrich.py +291 -0
  13. elasticsearch9/_async/client/eql.py +359 -0
  14. elasticsearch9/_async/client/esql.py +490 -0
  15. elasticsearch9/_async/client/features.py +130 -0
  16. elasticsearch9/_async/client/fleet.py +658 -0
  17. elasticsearch9/_async/client/graph.py +113 -0
  18. elasticsearch9/_async/client/ilm.py +668 -0
  19. elasticsearch9/_async/client/indices.py +5582 -0
  20. elasticsearch9/_async/client/inference.py +2247 -0
  21. elasticsearch9/_async/client/ingest.py +766 -0
  22. elasticsearch9/_async/client/license.py +400 -0
  23. elasticsearch9/_async/client/logstash.py +176 -0
  24. elasticsearch9/_async/client/migration.py +160 -0
  25. elasticsearch9/_async/client/ml.py +5835 -0
  26. elasticsearch9/_async/client/monitoring.py +100 -0
  27. elasticsearch9/_async/client/nodes.py +543 -0
  28. elasticsearch9/_async/client/query_rules.py +485 -0
  29. elasticsearch9/_async/client/rollup.py +616 -0
  30. elasticsearch9/_async/client/search_application.py +574 -0
  31. elasticsearch9/_async/client/searchable_snapshots.py +313 -0
  32. elasticsearch9/_async/client/security.py +4688 -0
  33. elasticsearch9/_async/client/shutdown.py +268 -0
  34. elasticsearch9/_async/client/simulate.py +145 -0
  35. elasticsearch9/_async/client/slm.py +559 -0
  36. elasticsearch9/_async/client/snapshot.py +1338 -0
  37. elasticsearch9/_async/client/sql.py +469 -0
  38. elasticsearch9/_async/client/ssl.py +76 -0
  39. elasticsearch9/_async/client/synonyms.py +413 -0
  40. elasticsearch9/_async/client/tasks.py +295 -0
  41. elasticsearch9/_async/client/text_structure.py +664 -0
  42. elasticsearch9/_async/client/transform.py +922 -0
  43. elasticsearch9/_async/client/utils.py +48 -0
  44. elasticsearch9/_async/client/watcher.py +894 -0
  45. elasticsearch9/_async/client/xpack.py +134 -0
  46. elasticsearch9/_async/helpers.py +596 -0
  47. elasticsearch9/_otel.py +110 -0
  48. elasticsearch9/_sync/__init__.py +16 -0
  49. elasticsearch9/_sync/client/__init__.py +6529 -0
  50. elasticsearch9/_sync/client/_base.py +430 -0
  51. elasticsearch9/_sync/client/async_search.py +637 -0
  52. elasticsearch9/_sync/client/autoscaling.py +252 -0
  53. elasticsearch9/_sync/client/cat.py +2995 -0
  54. elasticsearch9/_sync/client/ccr.py +1043 -0
  55. elasticsearch9/_sync/client/cluster.py +1223 -0
  56. elasticsearch9/_sync/client/connector.py +1978 -0
  57. elasticsearch9/_sync/client/dangling_indices.py +192 -0
  58. elasticsearch9/_sync/client/enrich.py +291 -0
  59. elasticsearch9/_sync/client/eql.py +359 -0
  60. elasticsearch9/_sync/client/esql.py +490 -0
  61. elasticsearch9/_sync/client/features.py +130 -0
  62. elasticsearch9/_sync/client/fleet.py +658 -0
  63. elasticsearch9/_sync/client/graph.py +113 -0
  64. elasticsearch9/_sync/client/ilm.py +668 -0
  65. elasticsearch9/_sync/client/indices.py +5582 -0
  66. elasticsearch9/_sync/client/inference.py +2247 -0
  67. elasticsearch9/_sync/client/ingest.py +766 -0
  68. elasticsearch9/_sync/client/license.py +400 -0
  69. elasticsearch9/_sync/client/logstash.py +176 -0
  70. elasticsearch9/_sync/client/migration.py +160 -0
  71. elasticsearch9/_sync/client/ml.py +5835 -0
  72. elasticsearch9/_sync/client/monitoring.py +100 -0
  73. elasticsearch9/_sync/client/nodes.py +543 -0
  74. elasticsearch9/_sync/client/query_rules.py +485 -0
  75. elasticsearch9/_sync/client/rollup.py +616 -0
  76. elasticsearch9/_sync/client/search_application.py +574 -0
  77. elasticsearch9/_sync/client/searchable_snapshots.py +313 -0
  78. elasticsearch9/_sync/client/security.py +4688 -0
  79. elasticsearch9/_sync/client/shutdown.py +268 -0
  80. elasticsearch9/_sync/client/simulate.py +145 -0
  81. elasticsearch9/_sync/client/slm.py +559 -0
  82. elasticsearch9/_sync/client/snapshot.py +1338 -0
  83. elasticsearch9/_sync/client/sql.py +469 -0
  84. elasticsearch9/_sync/client/ssl.py +76 -0
  85. elasticsearch9/_sync/client/synonyms.py +413 -0
  86. elasticsearch9/_sync/client/tasks.py +295 -0
  87. elasticsearch9/_sync/client/text_structure.py +664 -0
  88. elasticsearch9/_sync/client/transform.py +922 -0
  89. elasticsearch9/_sync/client/utils.py +475 -0
  90. elasticsearch9/_sync/client/watcher.py +894 -0
  91. elasticsearch9/_sync/client/xpack.py +134 -0
  92. elasticsearch9/_utils.py +34 -0
  93. elasticsearch9/_version.py +18 -0
  94. elasticsearch9/client.py +126 -0
  95. elasticsearch9/compat.py +79 -0
  96. elasticsearch9/dsl/__init__.py +203 -0
  97. elasticsearch9/dsl/_async/__init__.py +16 -0
  98. elasticsearch9/dsl/_async/document.py +522 -0
  99. elasticsearch9/dsl/_async/faceted_search.py +50 -0
  100. elasticsearch9/dsl/_async/index.py +639 -0
  101. elasticsearch9/dsl/_async/mapping.py +49 -0
  102. elasticsearch9/dsl/_async/search.py +237 -0
  103. elasticsearch9/dsl/_async/update_by_query.py +47 -0
  104. elasticsearch9/dsl/_sync/__init__.py +16 -0
  105. elasticsearch9/dsl/_sync/document.py +514 -0
  106. elasticsearch9/dsl/_sync/faceted_search.py +50 -0
  107. elasticsearch9/dsl/_sync/index.py +597 -0
  108. elasticsearch9/dsl/_sync/mapping.py +49 -0
  109. elasticsearch9/dsl/_sync/search.py +230 -0
  110. elasticsearch9/dsl/_sync/update_by_query.py +45 -0
  111. elasticsearch9/dsl/aggs.py +3734 -0
  112. elasticsearch9/dsl/analysis.py +341 -0
  113. elasticsearch9/dsl/async_connections.py +37 -0
  114. elasticsearch9/dsl/connections.py +142 -0
  115. elasticsearch9/dsl/document.py +20 -0
  116. elasticsearch9/dsl/document_base.py +444 -0
  117. elasticsearch9/dsl/exceptions.py +32 -0
  118. elasticsearch9/dsl/faceted_search.py +28 -0
  119. elasticsearch9/dsl/faceted_search_base.py +489 -0
  120. elasticsearch9/dsl/field.py +4392 -0
  121. elasticsearch9/dsl/function.py +180 -0
  122. elasticsearch9/dsl/index.py +23 -0
  123. elasticsearch9/dsl/index_base.py +178 -0
  124. elasticsearch9/dsl/mapping.py +19 -0
  125. elasticsearch9/dsl/mapping_base.py +219 -0
  126. elasticsearch9/dsl/query.py +2822 -0
  127. elasticsearch9/dsl/response/__init__.py +388 -0
  128. elasticsearch9/dsl/response/aggs.py +100 -0
  129. elasticsearch9/dsl/response/hit.py +53 -0
  130. elasticsearch9/dsl/search.py +20 -0
  131. elasticsearch9/dsl/search_base.py +1053 -0
  132. elasticsearch9/dsl/serializer.py +34 -0
  133. elasticsearch9/dsl/types.py +6453 -0
  134. elasticsearch9/dsl/update_by_query.py +19 -0
  135. elasticsearch9/dsl/update_by_query_base.py +149 -0
  136. elasticsearch9/dsl/utils.py +687 -0
  137. elasticsearch9/dsl/wrappers.py +144 -0
  138. elasticsearch9/exceptions.py +133 -0
  139. elasticsearch9/helpers/__init__.py +41 -0
  140. elasticsearch9/helpers/actions.py +875 -0
  141. elasticsearch9/helpers/errors.py +40 -0
  142. elasticsearch9/helpers/vectorstore/__init__.py +62 -0
  143. elasticsearch9/helpers/vectorstore/_async/__init__.py +16 -0
  144. elasticsearch9/helpers/vectorstore/_async/_utils.py +39 -0
  145. elasticsearch9/helpers/vectorstore/_async/embedding_service.py +89 -0
  146. elasticsearch9/helpers/vectorstore/_async/strategies.py +487 -0
  147. elasticsearch9/helpers/vectorstore/_async/vectorstore.py +421 -0
  148. elasticsearch9/helpers/vectorstore/_sync/__init__.py +16 -0
  149. elasticsearch9/helpers/vectorstore/_sync/_utils.py +39 -0
  150. elasticsearch9/helpers/vectorstore/_sync/embedding_service.py +89 -0
  151. elasticsearch9/helpers/vectorstore/_sync/strategies.py +487 -0
  152. elasticsearch9/helpers/vectorstore/_sync/vectorstore.py +421 -0
  153. elasticsearch9/helpers/vectorstore/_utils.py +116 -0
  154. elasticsearch9/py.typed +0 -0
  155. elasticsearch9/serializer.py +250 -0
  156. elasticsearch9-9.0.0.dist-info/METADATA +175 -0
  157. elasticsearch9-9.0.0.dist-info/RECORD +160 -0
  158. elasticsearch9-9.0.0.dist-info/WHEEL +4 -0
  159. elasticsearch9-9.0.0.dist-info/licenses/LICENSE +176 -0
  160. elasticsearch9-9.0.0.dist-info/licenses/NOTICE +2 -0
@@ -0,0 +1,144 @@
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 operator
19
+ from typing import (
20
+ TYPE_CHECKING,
21
+ Any,
22
+ Callable,
23
+ ClassVar,
24
+ Dict,
25
+ Literal,
26
+ Mapping,
27
+ Optional,
28
+ Tuple,
29
+ TypeVar,
30
+ Union,
31
+ cast,
32
+ )
33
+
34
+ if TYPE_CHECKING:
35
+ from _operator import _SupportsComparison
36
+
37
+ from typing_extensions import TypeAlias
38
+
39
+ from .utils import AttrDict
40
+
41
+ ComparisonOperators: TypeAlias = Literal["lt", "lte", "gt", "gte"]
42
+ RangeValT = TypeVar("RangeValT", bound="_SupportsComparison")
43
+
44
+ __all__ = ["Range"]
45
+
46
+
47
+ class Range(AttrDict[RangeValT]):
48
+ OPS: ClassVar[
49
+ Mapping[
50
+ ComparisonOperators,
51
+ Callable[["_SupportsComparison", "_SupportsComparison"], bool],
52
+ ]
53
+ ] = {
54
+ "lt": operator.lt,
55
+ "lte": operator.le,
56
+ "gt": operator.gt,
57
+ "gte": operator.ge,
58
+ }
59
+
60
+ def __init__(
61
+ self,
62
+ d: Optional[Dict[str, RangeValT]] = None,
63
+ /,
64
+ **kwargs: RangeValT,
65
+ ):
66
+ if d is not None and (kwargs or not isinstance(d, dict)):
67
+ raise ValueError(
68
+ "Range accepts a single dictionary or a set of keyword arguments."
69
+ )
70
+
71
+ if d is None:
72
+ data = kwargs
73
+ else:
74
+ data = d
75
+
76
+ for k in data:
77
+ if k not in self.OPS:
78
+ raise ValueError(f"Range received an unknown operator {k!r}")
79
+
80
+ if "gt" in data and "gte" in data:
81
+ raise ValueError("You cannot specify both gt and gte for Range.")
82
+
83
+ if "lt" in data and "lte" in data:
84
+ raise ValueError("You cannot specify both lt and lte for Range.")
85
+
86
+ super().__init__(data)
87
+
88
+ def __repr__(self) -> str:
89
+ return "Range(%s)" % ", ".join("%s=%r" % op for op in self._d_.items())
90
+
91
+ def __contains__(self, item: object) -> bool:
92
+ if isinstance(item, str):
93
+ return super().__contains__(item)
94
+
95
+ item_supports_comp = any(hasattr(item, f"__{op}__") for op in self.OPS)
96
+ if not item_supports_comp:
97
+ return False
98
+
99
+ for op in self.OPS:
100
+ if op in self._d_ and not self.OPS[op](
101
+ cast("_SupportsComparison", item), self._d_[op]
102
+ ):
103
+ return False
104
+ return True
105
+
106
+ @property
107
+ def upper(self) -> Union[Tuple[RangeValT, bool], Tuple[None, Literal[False]]]:
108
+ if "lt" in self._d_:
109
+ return self._d_["lt"], False
110
+ if "lte" in self._d_:
111
+ return self._d_["lte"], True
112
+ return None, False
113
+
114
+ @property
115
+ def lower(self) -> Union[Tuple[RangeValT, bool], Tuple[None, Literal[False]]]:
116
+ if "gt" in self._d_:
117
+ return self._d_["gt"], False
118
+ if "gte" in self._d_:
119
+ return self._d_["gte"], True
120
+ return None, False
121
+
122
+
123
+ class AggregationRange(AttrDict[Any]):
124
+ """
125
+ :arg from: Start of the range (inclusive).
126
+ :arg key: Custom key to return the range with.
127
+ :arg to: End of the range (exclusive).
128
+ """
129
+
130
+ def __init__(
131
+ self,
132
+ *,
133
+ from_: Any = None,
134
+ key: Optional[str] = None,
135
+ to: Any = None,
136
+ **kwargs: Any,
137
+ ):
138
+ if from_ is not None:
139
+ kwargs["from_"] = from_
140
+ if key is not None:
141
+ kwargs["key"] = key
142
+ if to is not None:
143
+ kwargs["to"] = to
144
+ super().__init__(kwargs)
@@ -0,0 +1,133 @@
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 Any, Dict, Type
19
+
20
+ from elastic_transport import ApiError as _ApiError
21
+ from elastic_transport import ConnectionError as ConnectionError
22
+ from elastic_transport import ConnectionTimeout as ConnectionTimeout
23
+ from elastic_transport import SerializationError as SerializationError
24
+ from elastic_transport import TlsError as SSLError
25
+ from elastic_transport import TransportError as TransportError
26
+ from elastic_transport import TransportWarning
27
+
28
+ __all__ = [
29
+ "SerializationError",
30
+ "TransportError",
31
+ "ConnectionError",
32
+ "SSLError",
33
+ "ConnectionTimeout",
34
+ "AuthorizationException",
35
+ "AuthenticationException",
36
+ "NotFoundError",
37
+ "ConflictError",
38
+ "BadRequestError",
39
+ ]
40
+
41
+
42
+ class ApiError(_ApiError):
43
+ @property
44
+ def status_code(self) -> int:
45
+ """Backwards-compatible way to access ``self.meta.status``"""
46
+ return self.meta.status
47
+
48
+ @property
49
+ def error(self) -> str:
50
+ """Backwards-compatible way to access ``self.message``"""
51
+ return self.message
52
+
53
+ @property
54
+ def info(self) -> Any:
55
+ """Backwards-compatible way to access ``self.body``"""
56
+ return self.body
57
+
58
+ def __str__(self) -> str:
59
+ cause = ""
60
+ try:
61
+ if self.body and isinstance(self.body, dict) and "error" in self.body:
62
+ if isinstance(self.body["error"], dict):
63
+ root_cause = self.body["error"]["root_cause"][0]
64
+ cause = ", ".join(
65
+ filter(
66
+ None,
67
+ [
68
+ repr(root_cause["reason"]),
69
+ root_cause.get("resource.id"),
70
+ root_cause.get("resource.type"),
71
+ ],
72
+ )
73
+ )
74
+
75
+ else:
76
+ cause = repr(self.body["error"])
77
+ except LookupError:
78
+ pass
79
+ msg = ", ".join(filter(None, [str(self.status_code), repr(self.error), cause]))
80
+ return f"{self.__class__.__name__}({msg})"
81
+
82
+
83
+ class UnsupportedProductError(ApiError):
84
+ """Error which is raised when the client detects
85
+ it's not connected to a supported product.
86
+ """
87
+
88
+ def __str__(self) -> str:
89
+ return self.message
90
+
91
+
92
+ class NotFoundError(ApiError):
93
+ """Exception representing a 404 status code."""
94
+
95
+
96
+ class ConflictError(ApiError):
97
+ """Exception representing a 409 status code."""
98
+
99
+
100
+ class BadRequestError(ApiError):
101
+ """Exception representing a 400 status code."""
102
+
103
+
104
+ class AuthenticationException(ApiError):
105
+ """Exception representing a 401 status code."""
106
+
107
+
108
+ class AuthorizationException(ApiError):
109
+ """Exception representing a 403 status code."""
110
+
111
+
112
+ class ElasticsearchWarning(TransportWarning):
113
+ """Warning that is raised when a deprecated option
114
+ or incorrect usage is flagged via the 'Warning' HTTP header.
115
+ """
116
+
117
+
118
+ class GeneralAvailabilityWarning(TransportWarning):
119
+ """Warning that is raised when a feature is not yet GA."""
120
+
121
+
122
+ # Aliases for backwards compatibility
123
+ ElasticsearchDeprecationWarning = ElasticsearchWarning
124
+ RequestError = BadRequestError
125
+
126
+
127
+ HTTP_EXCEPTIONS: Dict[int, Type[ApiError]] = {
128
+ 400: BadRequestError,
129
+ 401: AuthenticationException,
130
+ 403: AuthorizationException,
131
+ 404: NotFoundError,
132
+ 409: ConflictError,
133
+ }
@@ -0,0 +1,41 @@
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 .._async.helpers import async_bulk, async_reindex, async_scan, async_streaming_bulk
19
+ from .._utils import fixup_module_metadata
20
+ from .actions import _chunk_actions # noqa: F401
21
+ from .actions import _process_bulk_chunk # noqa: F401
22
+ from .actions import bulk, expand_action, parallel_bulk, reindex, scan, streaming_bulk
23
+ from .errors import BulkIndexError, ScanError
24
+
25
+ __all__ = [
26
+ "BulkIndexError",
27
+ "ScanError",
28
+ "expand_action",
29
+ "streaming_bulk",
30
+ "bulk",
31
+ "parallel_bulk",
32
+ "scan",
33
+ "reindex",
34
+ "async_scan",
35
+ "async_bulk",
36
+ "async_reindex",
37
+ "async_streaming_bulk",
38
+ ]
39
+
40
+ fixup_module_metadata(__name__, globals())
41
+ del fixup_module_metadata