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,413 @@
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 typing as t
19
+
20
+ from elastic_transport import ObjectApiResponse
21
+
22
+ from ._base import NamespacedClient
23
+ from .utils import SKIP_IN_PATH, _quote, _rewrite_parameters
24
+
25
+
26
+ class SynonymsClient(NamespacedClient):
27
+
28
+ @_rewrite_parameters()
29
+ async def delete_synonym(
30
+ self,
31
+ *,
32
+ id: str,
33
+ error_trace: t.Optional[bool] = None,
34
+ filter_path: t.Optional[t.Union[str, t.Sequence[str]]] = None,
35
+ human: t.Optional[bool] = None,
36
+ pretty: t.Optional[bool] = None,
37
+ ) -> ObjectApiResponse[t.Any]:
38
+ """
39
+ .. raw:: html
40
+
41
+ <p>Delete a synonym set.</p>
42
+ <p>You can only delete a synonyms set that is not in use by any index analyzer.</p>
43
+ <p>Synonyms sets can be used in synonym graph token filters and synonym token filters.
44
+ These synonym filters can be used as part of search analyzers.</p>
45
+ <p>Analyzers need to be loaded when an index is restored (such as when a node starts, or the index becomes open).
46
+ Even if the analyzer is not used on any field mapping, it still needs to be loaded on the index recovery phase.</p>
47
+ <p>If any analyzers cannot be loaded, the index becomes unavailable and the cluster status becomes red or yellow as index shards are not available.
48
+ To prevent that, synonyms sets that are used in analyzers can't be deleted.
49
+ A delete request in this case will return a 400 response code.</p>
50
+ <p>To remove a synonyms set, you must first remove all indices that contain analyzers using it.
51
+ You can migrate an index by creating a new index that does not contain the token filter with the synonyms set, and use the reindex API in order to copy over the index data.
52
+ Once finished, you can delete the index.
53
+ When the synonyms set is not used in analyzers, you will be able to delete it.</p>
54
+
55
+
56
+ `<https://www.elastic.co/docs/api/doc/elasticsearch/v9/operation/operation-synonyms-delete-synonym>`_
57
+
58
+ :param id: The synonyms set identifier to delete.
59
+ """
60
+ if id in SKIP_IN_PATH:
61
+ raise ValueError("Empty value passed for parameter 'id'")
62
+ __path_parts: t.Dict[str, str] = {"id": _quote(id)}
63
+ __path = f'/_synonyms/{__path_parts["id"]}'
64
+ __query: t.Dict[str, t.Any] = {}
65
+ if error_trace is not None:
66
+ __query["error_trace"] = error_trace
67
+ if filter_path is not None:
68
+ __query["filter_path"] = filter_path
69
+ if human is not None:
70
+ __query["human"] = human
71
+ if pretty is not None:
72
+ __query["pretty"] = pretty
73
+ __headers = {"accept": "application/json"}
74
+ return await self.perform_request( # type: ignore[return-value]
75
+ "DELETE",
76
+ __path,
77
+ params=__query,
78
+ headers=__headers,
79
+ endpoint_id="synonyms.delete_synonym",
80
+ path_parts=__path_parts,
81
+ )
82
+
83
+ @_rewrite_parameters()
84
+ async def delete_synonym_rule(
85
+ self,
86
+ *,
87
+ set_id: str,
88
+ rule_id: str,
89
+ error_trace: t.Optional[bool] = None,
90
+ filter_path: t.Optional[t.Union[str, t.Sequence[str]]] = None,
91
+ human: t.Optional[bool] = None,
92
+ pretty: t.Optional[bool] = None,
93
+ ) -> ObjectApiResponse[t.Any]:
94
+ """
95
+ .. raw:: html
96
+
97
+ <p>Delete a synonym rule.
98
+ Delete a synonym rule from a synonym set.</p>
99
+
100
+
101
+ `<https://www.elastic.co/docs/api/doc/elasticsearch/v9/operation/operation-synonyms-delete-synonym-rule>`_
102
+
103
+ :param set_id: The ID of the synonym set to update.
104
+ :param rule_id: The ID of the synonym rule to delete.
105
+ """
106
+ if set_id in SKIP_IN_PATH:
107
+ raise ValueError("Empty value passed for parameter 'set_id'")
108
+ if rule_id in SKIP_IN_PATH:
109
+ raise ValueError("Empty value passed for parameter 'rule_id'")
110
+ __path_parts: t.Dict[str, str] = {
111
+ "set_id": _quote(set_id),
112
+ "rule_id": _quote(rule_id),
113
+ }
114
+ __path = f'/_synonyms/{__path_parts["set_id"]}/{__path_parts["rule_id"]}'
115
+ __query: t.Dict[str, t.Any] = {}
116
+ if error_trace is not None:
117
+ __query["error_trace"] = error_trace
118
+ if filter_path is not None:
119
+ __query["filter_path"] = filter_path
120
+ if human is not None:
121
+ __query["human"] = human
122
+ if pretty is not None:
123
+ __query["pretty"] = pretty
124
+ __headers = {"accept": "application/json"}
125
+ return await self.perform_request( # type: ignore[return-value]
126
+ "DELETE",
127
+ __path,
128
+ params=__query,
129
+ headers=__headers,
130
+ endpoint_id="synonyms.delete_synonym_rule",
131
+ path_parts=__path_parts,
132
+ )
133
+
134
+ @_rewrite_parameters(
135
+ parameter_aliases={"from": "from_"},
136
+ )
137
+ async def get_synonym(
138
+ self,
139
+ *,
140
+ id: str,
141
+ error_trace: t.Optional[bool] = None,
142
+ filter_path: t.Optional[t.Union[str, t.Sequence[str]]] = None,
143
+ from_: t.Optional[int] = None,
144
+ human: t.Optional[bool] = None,
145
+ pretty: t.Optional[bool] = None,
146
+ size: t.Optional[int] = None,
147
+ ) -> ObjectApiResponse[t.Any]:
148
+ """
149
+ .. raw:: html
150
+
151
+ <p>Get a synonym set.</p>
152
+
153
+
154
+ `<https://www.elastic.co/docs/api/doc/elasticsearch/v9/operation/operation-synonyms-get-synonym>`_
155
+
156
+ :param id: The synonyms set identifier to retrieve.
157
+ :param from_: The starting offset for query rules to retrieve.
158
+ :param size: The max number of query rules to retrieve.
159
+ """
160
+ if id in SKIP_IN_PATH:
161
+ raise ValueError("Empty value passed for parameter 'id'")
162
+ __path_parts: t.Dict[str, str] = {"id": _quote(id)}
163
+ __path = f'/_synonyms/{__path_parts["id"]}'
164
+ __query: t.Dict[str, t.Any] = {}
165
+ if error_trace is not None:
166
+ __query["error_trace"] = error_trace
167
+ if filter_path is not None:
168
+ __query["filter_path"] = filter_path
169
+ if from_ is not None:
170
+ __query["from"] = from_
171
+ if human is not None:
172
+ __query["human"] = human
173
+ if pretty is not None:
174
+ __query["pretty"] = pretty
175
+ if size is not None:
176
+ __query["size"] = size
177
+ __headers = {"accept": "application/json"}
178
+ return await self.perform_request( # type: ignore[return-value]
179
+ "GET",
180
+ __path,
181
+ params=__query,
182
+ headers=__headers,
183
+ endpoint_id="synonyms.get_synonym",
184
+ path_parts=__path_parts,
185
+ )
186
+
187
+ @_rewrite_parameters()
188
+ async def get_synonym_rule(
189
+ self,
190
+ *,
191
+ set_id: str,
192
+ rule_id: str,
193
+ error_trace: t.Optional[bool] = None,
194
+ filter_path: t.Optional[t.Union[str, t.Sequence[str]]] = None,
195
+ human: t.Optional[bool] = None,
196
+ pretty: t.Optional[bool] = None,
197
+ ) -> ObjectApiResponse[t.Any]:
198
+ """
199
+ .. raw:: html
200
+
201
+ <p>Get a synonym rule.
202
+ Get a synonym rule from a synonym set.</p>
203
+
204
+
205
+ `<https://www.elastic.co/docs/api/doc/elasticsearch/v9/operation/operation-synonyms-get-synonym-rule>`_
206
+
207
+ :param set_id: The ID of the synonym set to retrieve the synonym rule from.
208
+ :param rule_id: The ID of the synonym rule to retrieve.
209
+ """
210
+ if set_id in SKIP_IN_PATH:
211
+ raise ValueError("Empty value passed for parameter 'set_id'")
212
+ if rule_id in SKIP_IN_PATH:
213
+ raise ValueError("Empty value passed for parameter 'rule_id'")
214
+ __path_parts: t.Dict[str, str] = {
215
+ "set_id": _quote(set_id),
216
+ "rule_id": _quote(rule_id),
217
+ }
218
+ __path = f'/_synonyms/{__path_parts["set_id"]}/{__path_parts["rule_id"]}'
219
+ __query: t.Dict[str, t.Any] = {}
220
+ if error_trace is not None:
221
+ __query["error_trace"] = error_trace
222
+ if filter_path is not None:
223
+ __query["filter_path"] = filter_path
224
+ if human is not None:
225
+ __query["human"] = human
226
+ if pretty is not None:
227
+ __query["pretty"] = pretty
228
+ __headers = {"accept": "application/json"}
229
+ return await self.perform_request( # type: ignore[return-value]
230
+ "GET",
231
+ __path,
232
+ params=__query,
233
+ headers=__headers,
234
+ endpoint_id="synonyms.get_synonym_rule",
235
+ path_parts=__path_parts,
236
+ )
237
+
238
+ @_rewrite_parameters(
239
+ parameter_aliases={"from": "from_"},
240
+ )
241
+ async def get_synonyms_sets(
242
+ self,
243
+ *,
244
+ error_trace: t.Optional[bool] = None,
245
+ filter_path: t.Optional[t.Union[str, t.Sequence[str]]] = None,
246
+ from_: t.Optional[int] = None,
247
+ human: t.Optional[bool] = None,
248
+ pretty: t.Optional[bool] = None,
249
+ size: t.Optional[int] = None,
250
+ ) -> ObjectApiResponse[t.Any]:
251
+ """
252
+ .. raw:: html
253
+
254
+ <p>Get all synonym sets.
255
+ Get a summary of all defined synonym sets.</p>
256
+
257
+
258
+ `<https://www.elastic.co/docs/api/doc/elasticsearch/v9/operation/operation-synonyms-get-synonym>`_
259
+
260
+ :param from_: The starting offset for synonyms sets to retrieve.
261
+ :param size: The maximum number of synonyms sets to retrieve.
262
+ """
263
+ __path_parts: t.Dict[str, str] = {}
264
+ __path = "/_synonyms"
265
+ __query: t.Dict[str, t.Any] = {}
266
+ if error_trace is not None:
267
+ __query["error_trace"] = error_trace
268
+ if filter_path is not None:
269
+ __query["filter_path"] = filter_path
270
+ if from_ is not None:
271
+ __query["from"] = from_
272
+ if human is not None:
273
+ __query["human"] = human
274
+ if pretty is not None:
275
+ __query["pretty"] = pretty
276
+ if size is not None:
277
+ __query["size"] = size
278
+ __headers = {"accept": "application/json"}
279
+ return await self.perform_request( # type: ignore[return-value]
280
+ "GET",
281
+ __path,
282
+ params=__query,
283
+ headers=__headers,
284
+ endpoint_id="synonyms.get_synonyms_sets",
285
+ path_parts=__path_parts,
286
+ )
287
+
288
+ @_rewrite_parameters(
289
+ body_fields=("synonyms_set",),
290
+ )
291
+ async def put_synonym(
292
+ self,
293
+ *,
294
+ id: str,
295
+ synonyms_set: t.Optional[
296
+ t.Union[t.Mapping[str, t.Any], t.Sequence[t.Mapping[str, t.Any]]]
297
+ ] = None,
298
+ error_trace: t.Optional[bool] = None,
299
+ filter_path: t.Optional[t.Union[str, t.Sequence[str]]] = None,
300
+ human: t.Optional[bool] = None,
301
+ pretty: t.Optional[bool] = None,
302
+ body: t.Optional[t.Dict[str, t.Any]] = None,
303
+ ) -> ObjectApiResponse[t.Any]:
304
+ """
305
+ .. raw:: html
306
+
307
+ <p>Create or update a synonym set.
308
+ Synonyms sets are limited to a maximum of 10,000 synonym rules per set.
309
+ If you need to manage more synonym rules, you can create multiple synonym sets.</p>
310
+ <p>When an existing synonyms set is updated, the search analyzers that use the synonyms set are reloaded automatically for all indices.
311
+ This is equivalent to invoking the reload search analyzers API for all indices that use the synonyms set.</p>
312
+
313
+
314
+ `<https://www.elastic.co/docs/api/doc/elasticsearch/v9/operation/operation-synonyms-put-synonym>`_
315
+
316
+ :param id: The ID of the synonyms set to be created or updated.
317
+ :param synonyms_set: The synonym rules definitions for the synonyms set.
318
+ """
319
+ if id in SKIP_IN_PATH:
320
+ raise ValueError("Empty value passed for parameter 'id'")
321
+ if synonyms_set is None and body is None:
322
+ raise ValueError("Empty value passed for parameter 'synonyms_set'")
323
+ __path_parts: t.Dict[str, str] = {"id": _quote(id)}
324
+ __path = f'/_synonyms/{__path_parts["id"]}'
325
+ __query: t.Dict[str, t.Any] = {}
326
+ __body: t.Dict[str, t.Any] = body if body is not None else {}
327
+ if error_trace is not None:
328
+ __query["error_trace"] = error_trace
329
+ if filter_path is not None:
330
+ __query["filter_path"] = filter_path
331
+ if human is not None:
332
+ __query["human"] = human
333
+ if pretty is not None:
334
+ __query["pretty"] = pretty
335
+ if not __body:
336
+ if synonyms_set is not None:
337
+ __body["synonyms_set"] = synonyms_set
338
+ __headers = {"accept": "application/json", "content-type": "application/json"}
339
+ return await self.perform_request( # type: ignore[return-value]
340
+ "PUT",
341
+ __path,
342
+ params=__query,
343
+ headers=__headers,
344
+ body=__body,
345
+ endpoint_id="synonyms.put_synonym",
346
+ path_parts=__path_parts,
347
+ )
348
+
349
+ @_rewrite_parameters(
350
+ body_fields=("synonyms",),
351
+ )
352
+ async def put_synonym_rule(
353
+ self,
354
+ *,
355
+ set_id: str,
356
+ rule_id: str,
357
+ synonyms: t.Optional[str] = None,
358
+ error_trace: t.Optional[bool] = None,
359
+ filter_path: t.Optional[t.Union[str, t.Sequence[str]]] = None,
360
+ human: t.Optional[bool] = None,
361
+ pretty: t.Optional[bool] = None,
362
+ body: t.Optional[t.Dict[str, t.Any]] = None,
363
+ ) -> ObjectApiResponse[t.Any]:
364
+ """
365
+ .. raw:: html
366
+
367
+ <p>Create or update a synonym rule.
368
+ Create or update a synonym rule in a synonym set.</p>
369
+ <p>If any of the synonym rules included is invalid, the API returns an error.</p>
370
+ <p>When you update a synonym rule, all analyzers using the synonyms set will be reloaded automatically to reflect the new rule.</p>
371
+
372
+
373
+ `<https://www.elastic.co/docs/api/doc/elasticsearch/v9/operation/operation-synonyms-put-synonym-rule>`_
374
+
375
+ :param set_id: The ID of the synonym set.
376
+ :param rule_id: The ID of the synonym rule to be updated or created.
377
+ :param synonyms: The synonym rule information definition, which must be in Solr
378
+ format.
379
+ """
380
+ if set_id in SKIP_IN_PATH:
381
+ raise ValueError("Empty value passed for parameter 'set_id'")
382
+ if rule_id in SKIP_IN_PATH:
383
+ raise ValueError("Empty value passed for parameter 'rule_id'")
384
+ if synonyms is None and body is None:
385
+ raise ValueError("Empty value passed for parameter 'synonyms'")
386
+ __path_parts: t.Dict[str, str] = {
387
+ "set_id": _quote(set_id),
388
+ "rule_id": _quote(rule_id),
389
+ }
390
+ __path = f'/_synonyms/{__path_parts["set_id"]}/{__path_parts["rule_id"]}'
391
+ __query: t.Dict[str, t.Any] = {}
392
+ __body: t.Dict[str, t.Any] = body if body is not None else {}
393
+ if error_trace is not None:
394
+ __query["error_trace"] = error_trace
395
+ if filter_path is not None:
396
+ __query["filter_path"] = filter_path
397
+ if human is not None:
398
+ __query["human"] = human
399
+ if pretty is not None:
400
+ __query["pretty"] = pretty
401
+ if not __body:
402
+ if synonyms is not None:
403
+ __body["synonyms"] = synonyms
404
+ __headers = {"accept": "application/json", "content-type": "application/json"}
405
+ return await self.perform_request( # type: ignore[return-value]
406
+ "PUT",
407
+ __path,
408
+ params=__query,
409
+ headers=__headers,
410
+ body=__body,
411
+ endpoint_id="synonyms.put_synonym_rule",
412
+ path_parts=__path_parts,
413
+ )