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,2816 @@
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 collections.abc
19
+ from copy import deepcopy
20
+ from itertools import chain
21
+ from typing import (
22
+ TYPE_CHECKING,
23
+ Any,
24
+ Callable,
25
+ ClassVar,
26
+ Dict,
27
+ List,
28
+ Literal,
29
+ Mapping,
30
+ MutableMapping,
31
+ Optional,
32
+ Protocol,
33
+ Sequence,
34
+ TypeVar,
35
+ Union,
36
+ cast,
37
+ overload,
38
+ )
39
+
40
+ from elastic_transport.client_utils import DEFAULT
41
+
42
+ # 'SF' looks unused but the test suite assumes it's available
43
+ # from this module so others are liable to do so as well.
44
+ from .function import SF # noqa: F401
45
+ from .function import ScoreFunction
46
+ from .utils import DslBase
47
+
48
+ if TYPE_CHECKING:
49
+ from elastic_transport.client_utils import DefaultType
50
+
51
+ from . import types, wrappers
52
+ from .document_base import InstrumentedField
53
+
54
+ _T = TypeVar("_T")
55
+ _M = TypeVar("_M", bound=Mapping[str, Any])
56
+
57
+
58
+ class QProxiedProtocol(Protocol[_T]):
59
+ _proxied: _T
60
+
61
+
62
+ @overload
63
+ def Q(name_or_query: MutableMapping[str, _M]) -> "Query": ...
64
+
65
+
66
+ @overload
67
+ def Q(name_or_query: "Query") -> "Query": ...
68
+
69
+
70
+ @overload
71
+ def Q(name_or_query: QProxiedProtocol[_T]) -> _T: ...
72
+
73
+
74
+ @overload
75
+ def Q(name_or_query: str = "match_all", **params: Any) -> "Query": ...
76
+
77
+
78
+ def Q(
79
+ name_or_query: Union[
80
+ str,
81
+ "Query",
82
+ QProxiedProtocol[_T],
83
+ MutableMapping[str, _M],
84
+ ] = "match_all",
85
+ **params: Any,
86
+ ) -> Union["Query", _T]:
87
+ # {"match": {"title": "python"}}
88
+ if isinstance(name_or_query, collections.abc.MutableMapping):
89
+ if params:
90
+ raise ValueError("Q() cannot accept parameters when passing in a dict.")
91
+ if len(name_or_query) != 1:
92
+ raise ValueError(
93
+ 'Q() can only accept dict with a single query ({"match": {...}}). '
94
+ "Instead it got (%r)" % name_or_query
95
+ )
96
+ name, q_params = deepcopy(name_or_query).popitem()
97
+ return Query.get_dsl_class(name)(_expand__to_dot=False, **q_params)
98
+
99
+ # MatchAll()
100
+ if isinstance(name_or_query, Query):
101
+ if params:
102
+ raise ValueError(
103
+ "Q() cannot accept parameters when passing in a Query object."
104
+ )
105
+ return name_or_query
106
+
107
+ # s.query = Q('filtered', query=s.query)
108
+ if hasattr(name_or_query, "_proxied"):
109
+ return cast(QProxiedProtocol[_T], name_or_query)._proxied
110
+
111
+ # "match", title="python"
112
+ return Query.get_dsl_class(name_or_query)(**params)
113
+
114
+
115
+ class Query(DslBase):
116
+ _type_name = "query"
117
+ _type_shortcut = staticmethod(Q)
118
+ name: ClassVar[Optional[str]] = None
119
+
120
+ # Add type annotations for methods not defined in every subclass
121
+ __ror__: ClassVar[Callable[["Query", "Query"], "Query"]]
122
+ __radd__: ClassVar[Callable[["Query", "Query"], "Query"]]
123
+ __rand__: ClassVar[Callable[["Query", "Query"], "Query"]]
124
+
125
+ def __add__(self, other: "Query") -> "Query":
126
+ # make sure we give queries that know how to combine themselves
127
+ # preference
128
+ if hasattr(other, "__radd__"):
129
+ return other.__radd__(self)
130
+ return Bool(must=[self, other])
131
+
132
+ def __invert__(self) -> "Query":
133
+ return Bool(must_not=[self])
134
+
135
+ def __or__(self, other: "Query") -> "Query":
136
+ # make sure we give queries that know how to combine themselves
137
+ # preference
138
+ if hasattr(other, "__ror__"):
139
+ return other.__ror__(self)
140
+ return Bool(should=[self, other])
141
+
142
+ def __and__(self, other: "Query") -> "Query":
143
+ # make sure we give queries that know how to combine themselves
144
+ # preference
145
+ if hasattr(other, "__rand__"):
146
+ return other.__rand__(self)
147
+ return Bool(must=[self, other])
148
+
149
+
150
+ class Bool(Query):
151
+ """
152
+ matches documents matching boolean combinations of other queries.
153
+
154
+ :arg filter: The clause (query) must appear in matching documents.
155
+ However, unlike `must`, the score of the query will be ignored.
156
+ :arg minimum_should_match: Specifies the number or percentage of
157
+ `should` clauses returned documents must match.
158
+ :arg must: The clause (query) must appear in matching documents and
159
+ will contribute to the score.
160
+ :arg must_not: The clause (query) must not appear in the matching
161
+ documents. Because scoring is ignored, a score of `0` is returned
162
+ for all documents.
163
+ :arg should: The clause (query) should appear in the matching
164
+ document.
165
+ :arg boost: Floating point number used to decrease or increase the
166
+ relevance scores of the query. Boost values are relative to the
167
+ default value of 1.0. A boost value between 0 and 1.0 decreases
168
+ the relevance score. A value greater than 1.0 increases the
169
+ relevance score. Defaults to `1` if omitted.
170
+ :arg _name:
171
+ """
172
+
173
+ name = "bool"
174
+ _param_defs = {
175
+ "filter": {"type": "query", "multi": True},
176
+ "must": {"type": "query", "multi": True},
177
+ "must_not": {"type": "query", "multi": True},
178
+ "should": {"type": "query", "multi": True},
179
+ }
180
+
181
+ def __init__(
182
+ self,
183
+ *,
184
+ filter: Union[Query, Sequence[Query], "DefaultType"] = DEFAULT,
185
+ minimum_should_match: Union[int, str, "DefaultType"] = DEFAULT,
186
+ must: Union[Query, Sequence[Query], "DefaultType"] = DEFAULT,
187
+ must_not: Union[Query, Sequence[Query], "DefaultType"] = DEFAULT,
188
+ should: Union[Query, Sequence[Query], "DefaultType"] = DEFAULT,
189
+ boost: Union[float, "DefaultType"] = DEFAULT,
190
+ _name: Union[str, "DefaultType"] = DEFAULT,
191
+ **kwargs: Any,
192
+ ):
193
+ super().__init__(
194
+ filter=filter,
195
+ minimum_should_match=minimum_should_match,
196
+ must=must,
197
+ must_not=must_not,
198
+ should=should,
199
+ boost=boost,
200
+ _name=_name,
201
+ **kwargs,
202
+ )
203
+
204
+ def __add__(self, other: Query) -> "Bool":
205
+ q = self._clone()
206
+ if isinstance(other, Bool):
207
+ q.must += other.must
208
+ q.should += other.should
209
+ q.must_not += other.must_not
210
+ q.filter += other.filter
211
+ else:
212
+ q.must.append(other)
213
+ return q
214
+
215
+ __radd__ = __add__
216
+
217
+ def __or__(self, other: Query) -> Query:
218
+ for q in (self, other):
219
+ if isinstance(q, Bool) and not any(
220
+ (q.must, q.must_not, q.filter, getattr(q, "minimum_should_match", None))
221
+ ):
222
+ other = self if q is other else other
223
+ q = q._clone()
224
+ if isinstance(other, Bool) and not any(
225
+ (
226
+ other.must,
227
+ other.must_not,
228
+ other.filter,
229
+ getattr(other, "minimum_should_match", None),
230
+ )
231
+ ):
232
+ q.should.extend(other.should)
233
+ else:
234
+ q.should.append(other)
235
+ return q
236
+
237
+ return Bool(should=[self, other])
238
+
239
+ __ror__ = __or__
240
+
241
+ @property
242
+ def _min_should_match(self) -> int:
243
+ return getattr(
244
+ self,
245
+ "minimum_should_match",
246
+ 0 if not self.should or (self.must or self.filter) else 1,
247
+ )
248
+
249
+ def __invert__(self) -> Query:
250
+ # Because an empty Bool query is treated like
251
+ # MatchAll the inverse should be MatchNone
252
+ if not any(chain(self.must, self.filter, self.should, self.must_not)):
253
+ return MatchNone()
254
+
255
+ negations: List[Query] = []
256
+ for q in chain(self.must, self.filter):
257
+ negations.append(~q)
258
+
259
+ for q in self.must_not:
260
+ negations.append(q)
261
+
262
+ if self.should and self._min_should_match:
263
+ negations.append(Bool(must_not=self.should[:]))
264
+
265
+ if len(negations) == 1:
266
+ return negations[0]
267
+ return Bool(should=negations)
268
+
269
+ def __and__(self, other: Query) -> Query:
270
+ q = self._clone()
271
+ if isinstance(other, Bool):
272
+ q.must += other.must
273
+ q.must_not += other.must_not
274
+ q.filter += other.filter
275
+ q.should = []
276
+
277
+ # reset minimum_should_match as it will get calculated below
278
+ if "minimum_should_match" in q._params:
279
+ del q._params["minimum_should_match"]
280
+
281
+ for qx in (self, other):
282
+ min_should_match = qx._min_should_match
283
+ # TODO: percentages or negative numbers will fail here
284
+ # for now we report an error
285
+ if not isinstance(min_should_match, int) or min_should_match < 0:
286
+ raise ValueError(
287
+ "Can only combine queries with positive integer values for minimum_should_match"
288
+ )
289
+ # all subqueries are required
290
+ if len(qx.should) <= min_should_match:
291
+ q.must.extend(qx.should)
292
+ # not all of them are required, use it and remember min_should_match
293
+ elif not q.should:
294
+ q.minimum_should_match = min_should_match
295
+ q.should = qx.should
296
+ # all queries are optional, just extend should
297
+ elif q._min_should_match == 0 and min_should_match == 0:
298
+ q.should.extend(qx.should)
299
+ # not all are required, add a should list to the must with proper min_should_match
300
+ else:
301
+ q.must.append(
302
+ Bool(should=qx.should, minimum_should_match=min_should_match)
303
+ )
304
+ else:
305
+ if not (q.must or q.filter) and q.should:
306
+ q._params.setdefault("minimum_should_match", 1)
307
+ q.must.append(other)
308
+ return q
309
+
310
+ __rand__ = __and__
311
+
312
+
313
+ class Boosting(Query):
314
+ """
315
+ Returns documents matching a `positive` query while reducing the
316
+ relevance score of documents that also match a `negative` query.
317
+
318
+ :arg negative_boost: (required) Floating point number between 0 and
319
+ 1.0 used to decrease the relevance scores of documents matching
320
+ the `negative` query.
321
+ :arg negative: (required) Query used to decrease the relevance score
322
+ of matching documents.
323
+ :arg positive: (required) Any returned documents must match this
324
+ query.
325
+ :arg boost: Floating point number used to decrease or increase the
326
+ relevance scores of the query. Boost values are relative to the
327
+ default value of 1.0. A boost value between 0 and 1.0 decreases
328
+ the relevance score. A value greater than 1.0 increases the
329
+ relevance score. Defaults to `1` if omitted.
330
+ :arg _name:
331
+ """
332
+
333
+ name = "boosting"
334
+ _param_defs = {
335
+ "negative": {"type": "query"},
336
+ "positive": {"type": "query"},
337
+ }
338
+
339
+ def __init__(
340
+ self,
341
+ *,
342
+ negative_boost: Union[float, "DefaultType"] = DEFAULT,
343
+ negative: Union[Query, "DefaultType"] = DEFAULT,
344
+ positive: Union[Query, "DefaultType"] = DEFAULT,
345
+ boost: Union[float, "DefaultType"] = DEFAULT,
346
+ _name: Union[str, "DefaultType"] = DEFAULT,
347
+ **kwargs: Any,
348
+ ):
349
+ super().__init__(
350
+ negative_boost=negative_boost,
351
+ negative=negative,
352
+ positive=positive,
353
+ boost=boost,
354
+ _name=_name,
355
+ **kwargs,
356
+ )
357
+
358
+
359
+ class Common(Query):
360
+ """
361
+ :arg _field: The field to use in this query.
362
+ :arg _value: The query value for the field.
363
+ """
364
+
365
+ name = "common"
366
+
367
+ def __init__(
368
+ self,
369
+ _field: Union[str, "InstrumentedField", "DefaultType"] = DEFAULT,
370
+ _value: Union[
371
+ "types.CommonTermsQuery", Dict[str, Any], "DefaultType"
372
+ ] = DEFAULT,
373
+ **kwargs: Any,
374
+ ):
375
+ if _field is not DEFAULT:
376
+ kwargs[str(_field)] = _value
377
+ super().__init__(**kwargs)
378
+
379
+
380
+ class CombinedFields(Query):
381
+ """
382
+ The `combined_fields` query supports searching multiple text fields as
383
+ if their contents had been indexed into one combined field.
384
+
385
+ :arg fields: (required) List of fields to search. Field wildcard
386
+ patterns are allowed. Only `text` fields are supported, and they
387
+ must all have the same search `analyzer`.
388
+ :arg query: (required) Text to search for in the provided `fields`.
389
+ The `combined_fields` query analyzes the provided text before
390
+ performing a search.
391
+ :arg auto_generate_synonyms_phrase_query: If true, match phrase
392
+ queries are automatically created for multi-term synonyms.
393
+ Defaults to `True` if omitted.
394
+ :arg operator: Boolean logic used to interpret text in the query
395
+ value. Defaults to `or` if omitted.
396
+ :arg minimum_should_match: Minimum number of clauses that must match
397
+ for a document to be returned.
398
+ :arg zero_terms_query: Indicates whether no documents are returned if
399
+ the analyzer removes all tokens, such as when using a `stop`
400
+ filter. Defaults to `none` if omitted.
401
+ :arg boost: Floating point number used to decrease or increase the
402
+ relevance scores of the query. Boost values are relative to the
403
+ default value of 1.0. A boost value between 0 and 1.0 decreases
404
+ the relevance score. A value greater than 1.0 increases the
405
+ relevance score. Defaults to `1` if omitted.
406
+ :arg _name:
407
+ """
408
+
409
+ name = "combined_fields"
410
+
411
+ def __init__(
412
+ self,
413
+ *,
414
+ fields: Union[
415
+ Sequence[Union[str, "InstrumentedField"]], "DefaultType"
416
+ ] = DEFAULT,
417
+ query: Union[str, "DefaultType"] = DEFAULT,
418
+ auto_generate_synonyms_phrase_query: Union[bool, "DefaultType"] = DEFAULT,
419
+ operator: Union[Literal["or", "and"], "DefaultType"] = DEFAULT,
420
+ minimum_should_match: Union[int, str, "DefaultType"] = DEFAULT,
421
+ zero_terms_query: Union[Literal["none", "all"], "DefaultType"] = DEFAULT,
422
+ boost: Union[float, "DefaultType"] = DEFAULT,
423
+ _name: Union[str, "DefaultType"] = DEFAULT,
424
+ **kwargs: Any,
425
+ ):
426
+ super().__init__(
427
+ fields=fields,
428
+ query=query,
429
+ auto_generate_synonyms_phrase_query=auto_generate_synonyms_phrase_query,
430
+ operator=operator,
431
+ minimum_should_match=minimum_should_match,
432
+ zero_terms_query=zero_terms_query,
433
+ boost=boost,
434
+ _name=_name,
435
+ **kwargs,
436
+ )
437
+
438
+
439
+ class ConstantScore(Query):
440
+ """
441
+ Wraps a filter query and returns every matching document with a
442
+ relevance score equal to the `boost` parameter value.
443
+
444
+ :arg filter: (required) Filter query you wish to run. Any returned
445
+ documents must match this query. Filter queries do not calculate
446
+ relevance scores. To speed up performance, Elasticsearch
447
+ automatically caches frequently used filter queries.
448
+ :arg boost: Floating point number used to decrease or increase the
449
+ relevance scores of the query. Boost values are relative to the
450
+ default value of 1.0. A boost value between 0 and 1.0 decreases
451
+ the relevance score. A value greater than 1.0 increases the
452
+ relevance score. Defaults to `1` if omitted.
453
+ :arg _name:
454
+ """
455
+
456
+ name = "constant_score"
457
+ _param_defs = {
458
+ "filter": {"type": "query"},
459
+ }
460
+
461
+ def __init__(
462
+ self,
463
+ *,
464
+ filter: Union[Query, "DefaultType"] = DEFAULT,
465
+ boost: Union[float, "DefaultType"] = DEFAULT,
466
+ _name: Union[str, "DefaultType"] = DEFAULT,
467
+ **kwargs: Any,
468
+ ):
469
+ super().__init__(filter=filter, boost=boost, _name=_name, **kwargs)
470
+
471
+
472
+ class DisMax(Query):
473
+ """
474
+ Returns documents matching one or more wrapped queries, called query
475
+ clauses or clauses. If a returned document matches multiple query
476
+ clauses, the `dis_max` query assigns the document the highest
477
+ relevance score from any matching clause, plus a tie breaking
478
+ increment for any additional matching subqueries.
479
+
480
+ :arg queries: (required) One or more query clauses. Returned documents
481
+ must match one or more of these queries. If a document matches
482
+ multiple queries, Elasticsearch uses the highest relevance score.
483
+ :arg tie_breaker: Floating point number between 0 and 1.0 used to
484
+ increase the relevance scores of documents matching multiple query
485
+ clauses.
486
+ :arg boost: Floating point number used to decrease or increase the
487
+ relevance scores of the query. Boost values are relative to the
488
+ default value of 1.0. A boost value between 0 and 1.0 decreases
489
+ the relevance score. A value greater than 1.0 increases the
490
+ relevance score. Defaults to `1` if omitted.
491
+ :arg _name:
492
+ """
493
+
494
+ name = "dis_max"
495
+ _param_defs = {
496
+ "queries": {"type": "query", "multi": True},
497
+ }
498
+
499
+ def __init__(
500
+ self,
501
+ *,
502
+ queries: Union[Sequence[Query], "DefaultType"] = DEFAULT,
503
+ tie_breaker: Union[float, "DefaultType"] = DEFAULT,
504
+ boost: Union[float, "DefaultType"] = DEFAULT,
505
+ _name: Union[str, "DefaultType"] = DEFAULT,
506
+ **kwargs: Any,
507
+ ):
508
+ super().__init__(
509
+ queries=queries, tie_breaker=tie_breaker, boost=boost, _name=_name, **kwargs
510
+ )
511
+
512
+
513
+ class DistanceFeature(Query):
514
+ """
515
+ Boosts the relevance score of documents closer to a provided origin
516
+ date or point. For example, you can use this query to give more weight
517
+ to documents closer to a certain date or location.
518
+
519
+ :arg origin: (required) Date or point of origin used to calculate
520
+ distances. If the `field` value is a `date` or `date_nanos` field,
521
+ the `origin` value must be a date. Date Math, such as `now-1h`, is
522
+ supported. If the field value is a `geo_point` field, the `origin`
523
+ value must be a geopoint.
524
+ :arg pivot: (required) Distance from the `origin` at which relevance
525
+ scores receive half of the `boost` value. If the `field` value is
526
+ a `date` or `date_nanos` field, the `pivot` value must be a time
527
+ unit, such as `1h` or `10d`. If the `field` value is a `geo_point`
528
+ field, the `pivot` value must be a distance unit, such as `1km` or
529
+ `12m`.
530
+ :arg field: (required) Name of the field used to calculate distances.
531
+ This field must meet the following criteria: be a `date`,
532
+ `date_nanos` or `geo_point` field; have an `index` mapping
533
+ parameter value of `true`, which is the default; have an
534
+ `doc_values` mapping parameter value of `true`, which is the
535
+ default.
536
+ :arg boost: Floating point number used to decrease or increase the
537
+ relevance scores of the query. Boost values are relative to the
538
+ default value of 1.0. A boost value between 0 and 1.0 decreases
539
+ the relevance score. A value greater than 1.0 increases the
540
+ relevance score. Defaults to `1` if omitted.
541
+ :arg _name:
542
+ """
543
+
544
+ name = "distance_feature"
545
+
546
+ def __init__(
547
+ self,
548
+ *,
549
+ origin: Any = DEFAULT,
550
+ pivot: Any = DEFAULT,
551
+ field: Union[str, "InstrumentedField", "DefaultType"] = DEFAULT,
552
+ boost: Union[float, "DefaultType"] = DEFAULT,
553
+ _name: Union[str, "DefaultType"] = DEFAULT,
554
+ **kwargs: Any,
555
+ ):
556
+ super().__init__(
557
+ origin=origin, pivot=pivot, field=field, boost=boost, _name=_name, **kwargs
558
+ )
559
+
560
+
561
+ class Exists(Query):
562
+ """
563
+ Returns documents that contain an indexed value for a field.
564
+
565
+ :arg field: (required) Name of the field you wish to search.
566
+ :arg boost: Floating point number used to decrease or increase the
567
+ relevance scores of the query. Boost values are relative to the
568
+ default value of 1.0. A boost value between 0 and 1.0 decreases
569
+ the relevance score. A value greater than 1.0 increases the
570
+ relevance score. Defaults to `1` if omitted.
571
+ :arg _name:
572
+ """
573
+
574
+ name = "exists"
575
+
576
+ def __init__(
577
+ self,
578
+ *,
579
+ field: Union[str, "InstrumentedField", "DefaultType"] = DEFAULT,
580
+ boost: Union[float, "DefaultType"] = DEFAULT,
581
+ _name: Union[str, "DefaultType"] = DEFAULT,
582
+ **kwargs: Any,
583
+ ):
584
+ super().__init__(field=field, boost=boost, _name=_name, **kwargs)
585
+
586
+
587
+ class FunctionScore(Query):
588
+ """
589
+ The `function_score` enables you to modify the score of documents that
590
+ are retrieved by a query.
591
+
592
+ :arg boost_mode: Defines how he newly computed score is combined with
593
+ the score of the query Defaults to `multiply` if omitted.
594
+ :arg functions: One or more functions that compute a new score for
595
+ each document returned by the query.
596
+ :arg max_boost: Restricts the new score to not exceed the provided
597
+ limit.
598
+ :arg min_score: Excludes documents that do not meet the provided score
599
+ threshold.
600
+ :arg query: A query that determines the documents for which a new
601
+ score is computed.
602
+ :arg score_mode: Specifies how the computed scores are combined
603
+ Defaults to `multiply` if omitted.
604
+ :arg boost: Floating point number used to decrease or increase the
605
+ relevance scores of the query. Boost values are relative to the
606
+ default value of 1.0. A boost value between 0 and 1.0 decreases
607
+ the relevance score. A value greater than 1.0 increases the
608
+ relevance score. Defaults to `1` if omitted.
609
+ :arg _name:
610
+ """
611
+
612
+ name = "function_score"
613
+ _param_defs = {
614
+ "functions": {"type": "score_function", "multi": True},
615
+ "query": {"type": "query"},
616
+ "filter": {"type": "query"},
617
+ }
618
+
619
+ def __init__(
620
+ self,
621
+ *,
622
+ boost_mode: Union[
623
+ Literal["multiply", "replace", "sum", "avg", "max", "min"], "DefaultType"
624
+ ] = DEFAULT,
625
+ functions: Union[Sequence[ScoreFunction], "DefaultType"] = DEFAULT,
626
+ max_boost: Union[float, "DefaultType"] = DEFAULT,
627
+ min_score: Union[float, "DefaultType"] = DEFAULT,
628
+ query: Union[Query, "DefaultType"] = DEFAULT,
629
+ score_mode: Union[
630
+ Literal["multiply", "sum", "avg", "first", "max", "min"], "DefaultType"
631
+ ] = DEFAULT,
632
+ boost: Union[float, "DefaultType"] = DEFAULT,
633
+ _name: Union[str, "DefaultType"] = DEFAULT,
634
+ **kwargs: Any,
635
+ ):
636
+ if functions is DEFAULT:
637
+ functions = []
638
+ for name in ScoreFunction._classes:
639
+ if name in kwargs:
640
+ functions.append({name: kwargs.pop(name)}) # type: ignore[arg-type]
641
+ super().__init__(
642
+ boost_mode=boost_mode,
643
+ functions=functions,
644
+ max_boost=max_boost,
645
+ min_score=min_score,
646
+ query=query,
647
+ score_mode=score_mode,
648
+ boost=boost,
649
+ _name=_name,
650
+ **kwargs,
651
+ )
652
+
653
+
654
+ class Fuzzy(Query):
655
+ """
656
+ Returns documents that contain terms similar to the search term, as
657
+ measured by a Levenshtein edit distance.
658
+
659
+ :arg _field: The field to use in this query.
660
+ :arg _value: The query value for the field.
661
+ """
662
+
663
+ name = "fuzzy"
664
+
665
+ def __init__(
666
+ self,
667
+ _field: Union[str, "InstrumentedField", "DefaultType"] = DEFAULT,
668
+ _value: Union["types.FuzzyQuery", Dict[str, Any], "DefaultType"] = DEFAULT,
669
+ **kwargs: Any,
670
+ ):
671
+ if _field is not DEFAULT:
672
+ kwargs[str(_field)] = _value
673
+ super().__init__(**kwargs)
674
+
675
+
676
+ class GeoBoundingBox(Query):
677
+ """
678
+ Matches geo_point and geo_shape values that intersect a bounding box.
679
+
680
+ :arg _field: The field to use in this query.
681
+ :arg _value: The query value for the field.
682
+ :arg type:
683
+ :arg validation_method: Set to `IGNORE_MALFORMED` to accept geo points
684
+ with invalid latitude or longitude. Set to `COERCE` to also try to
685
+ infer correct latitude or longitude. Defaults to `'strict'` if
686
+ omitted.
687
+ :arg ignore_unmapped: Set to `true` to ignore an unmapped field and
688
+ not match any documents for this query. Set to `false` to throw an
689
+ exception if the field is not mapped.
690
+ :arg boost: Floating point number used to decrease or increase the
691
+ relevance scores of the query. Boost values are relative to the
692
+ default value of 1.0. A boost value between 0 and 1.0 decreases
693
+ the relevance score. A value greater than 1.0 increases the
694
+ relevance score. Defaults to `1` if omitted.
695
+ :arg _name:
696
+ """
697
+
698
+ name = "geo_bounding_box"
699
+
700
+ def __init__(
701
+ self,
702
+ _field: Union[str, "InstrumentedField", "DefaultType"] = DEFAULT,
703
+ _value: Union[
704
+ "types.CoordsGeoBounds",
705
+ "types.TopLeftBottomRightGeoBounds",
706
+ "types.TopRightBottomLeftGeoBounds",
707
+ "types.WktGeoBounds",
708
+ Dict[str, Any],
709
+ "DefaultType",
710
+ ] = DEFAULT,
711
+ *,
712
+ type: Union[Literal["memory", "indexed"], "DefaultType"] = DEFAULT,
713
+ validation_method: Union[
714
+ Literal["coerce", "ignore_malformed", "strict"], "DefaultType"
715
+ ] = DEFAULT,
716
+ ignore_unmapped: Union[bool, "DefaultType"] = DEFAULT,
717
+ boost: Union[float, "DefaultType"] = DEFAULT,
718
+ _name: Union[str, "DefaultType"] = DEFAULT,
719
+ **kwargs: Any,
720
+ ):
721
+ if _field is not DEFAULT:
722
+ kwargs[str(_field)] = _value
723
+ super().__init__(
724
+ type=type,
725
+ validation_method=validation_method,
726
+ ignore_unmapped=ignore_unmapped,
727
+ boost=boost,
728
+ _name=_name,
729
+ **kwargs,
730
+ )
731
+
732
+
733
+ class GeoDistance(Query):
734
+ """
735
+ Matches `geo_point` and `geo_shape` values within a given distance of
736
+ a geopoint.
737
+
738
+ :arg _field: The field to use in this query.
739
+ :arg _value: The query value for the field.
740
+ :arg distance: (required) The radius of the circle centred on the
741
+ specified location. Points which fall into this circle are
742
+ considered to be matches.
743
+ :arg distance_type: How to compute the distance. Set to `plane` for a
744
+ faster calculation that's inaccurate on long distances and close
745
+ to the poles. Defaults to `'arc'` if omitted.
746
+ :arg validation_method: Set to `IGNORE_MALFORMED` to accept geo points
747
+ with invalid latitude or longitude. Set to `COERCE` to also try to
748
+ infer correct latitude or longitude. Defaults to `'strict'` if
749
+ omitted.
750
+ :arg ignore_unmapped: Set to `true` to ignore an unmapped field and
751
+ not match any documents for this query. Set to `false` to throw an
752
+ exception if the field is not mapped.
753
+ :arg boost: Floating point number used to decrease or increase the
754
+ relevance scores of the query. Boost values are relative to the
755
+ default value of 1.0. A boost value between 0 and 1.0 decreases
756
+ the relevance score. A value greater than 1.0 increases the
757
+ relevance score. Defaults to `1` if omitted.
758
+ :arg _name:
759
+ """
760
+
761
+ name = "geo_distance"
762
+
763
+ def __init__(
764
+ self,
765
+ _field: Union[str, "InstrumentedField", "DefaultType"] = DEFAULT,
766
+ _value: Union[
767
+ "types.LatLonGeoLocation",
768
+ "types.GeoHashLocation",
769
+ Sequence[float],
770
+ str,
771
+ Dict[str, Any],
772
+ "DefaultType",
773
+ ] = DEFAULT,
774
+ *,
775
+ distance: Union[str, "DefaultType"] = DEFAULT,
776
+ distance_type: Union[Literal["arc", "plane"], "DefaultType"] = DEFAULT,
777
+ validation_method: Union[
778
+ Literal["coerce", "ignore_malformed", "strict"], "DefaultType"
779
+ ] = DEFAULT,
780
+ ignore_unmapped: Union[bool, "DefaultType"] = DEFAULT,
781
+ boost: Union[float, "DefaultType"] = DEFAULT,
782
+ _name: Union[str, "DefaultType"] = DEFAULT,
783
+ **kwargs: Any,
784
+ ):
785
+ if _field is not DEFAULT:
786
+ kwargs[str(_field)] = _value
787
+ super().__init__(
788
+ distance=distance,
789
+ distance_type=distance_type,
790
+ validation_method=validation_method,
791
+ ignore_unmapped=ignore_unmapped,
792
+ boost=boost,
793
+ _name=_name,
794
+ **kwargs,
795
+ )
796
+
797
+
798
+ class GeoGrid(Query):
799
+ """
800
+ Matches `geo_point` and `geo_shape` values that intersect a grid cell
801
+ from a GeoGrid aggregation.
802
+
803
+ :arg _field: The field to use in this query.
804
+ :arg _value: The query value for the field.
805
+ """
806
+
807
+ name = "geo_grid"
808
+
809
+ def __init__(
810
+ self,
811
+ _field: Union[str, "InstrumentedField", "DefaultType"] = DEFAULT,
812
+ _value: Union["types.GeoGridQuery", Dict[str, Any], "DefaultType"] = DEFAULT,
813
+ **kwargs: Any,
814
+ ):
815
+ if _field is not DEFAULT:
816
+ kwargs[str(_field)] = _value
817
+ super().__init__(**kwargs)
818
+
819
+
820
+ class GeoPolygon(Query):
821
+ """
822
+ :arg _field: The field to use in this query.
823
+ :arg _value: The query value for the field.
824
+ :arg validation_method: Defaults to `'strict'` if omitted.
825
+ :arg ignore_unmapped:
826
+ :arg boost: Floating point number used to decrease or increase the
827
+ relevance scores of the query. Boost values are relative to the
828
+ default value of 1.0. A boost value between 0 and 1.0 decreases
829
+ the relevance score. A value greater than 1.0 increases the
830
+ relevance score. Defaults to `1` if omitted.
831
+ :arg _name:
832
+ """
833
+
834
+ name = "geo_polygon"
835
+
836
+ def __init__(
837
+ self,
838
+ _field: Union[str, "InstrumentedField", "DefaultType"] = DEFAULT,
839
+ _value: Union[
840
+ "types.GeoPolygonPoints", Dict[str, Any], "DefaultType"
841
+ ] = DEFAULT,
842
+ *,
843
+ validation_method: Union[
844
+ Literal["coerce", "ignore_malformed", "strict"], "DefaultType"
845
+ ] = DEFAULT,
846
+ ignore_unmapped: Union[bool, "DefaultType"] = DEFAULT,
847
+ boost: Union[float, "DefaultType"] = DEFAULT,
848
+ _name: Union[str, "DefaultType"] = DEFAULT,
849
+ **kwargs: Any,
850
+ ):
851
+ if _field is not DEFAULT:
852
+ kwargs[str(_field)] = _value
853
+ super().__init__(
854
+ validation_method=validation_method,
855
+ ignore_unmapped=ignore_unmapped,
856
+ boost=boost,
857
+ _name=_name,
858
+ **kwargs,
859
+ )
860
+
861
+
862
+ class GeoShape(Query):
863
+ """
864
+ Filter documents indexed using either the `geo_shape` or the
865
+ `geo_point` type.
866
+
867
+ :arg _field: The field to use in this query.
868
+ :arg _value: The query value for the field.
869
+ :arg ignore_unmapped: Set to `true` to ignore an unmapped field and
870
+ not match any documents for this query. Set to `false` to throw an
871
+ exception if the field is not mapped.
872
+ :arg boost: Floating point number used to decrease or increase the
873
+ relevance scores of the query. Boost values are relative to the
874
+ default value of 1.0. A boost value between 0 and 1.0 decreases
875
+ the relevance score. A value greater than 1.0 increases the
876
+ relevance score. Defaults to `1` if omitted.
877
+ :arg _name:
878
+ """
879
+
880
+ name = "geo_shape"
881
+
882
+ def __init__(
883
+ self,
884
+ _field: Union[str, "InstrumentedField", "DefaultType"] = DEFAULT,
885
+ _value: Union[
886
+ "types.GeoShapeFieldQuery", Dict[str, Any], "DefaultType"
887
+ ] = DEFAULT,
888
+ *,
889
+ ignore_unmapped: Union[bool, "DefaultType"] = DEFAULT,
890
+ boost: Union[float, "DefaultType"] = DEFAULT,
891
+ _name: Union[str, "DefaultType"] = DEFAULT,
892
+ **kwargs: Any,
893
+ ):
894
+ if _field is not DEFAULT:
895
+ kwargs[str(_field)] = _value
896
+ super().__init__(
897
+ ignore_unmapped=ignore_unmapped, boost=boost, _name=_name, **kwargs
898
+ )
899
+
900
+
901
+ class HasChild(Query):
902
+ """
903
+ Returns parent documents whose joined child documents match a provided
904
+ query.
905
+
906
+ :arg query: (required) Query you wish to run on child documents of the
907
+ `type` field. If a child document matches the search, the query
908
+ returns the parent document.
909
+ :arg type: (required) Name of the child relationship mapped for the
910
+ `join` field.
911
+ :arg ignore_unmapped: Indicates whether to ignore an unmapped `type`
912
+ and not return any documents instead of an error.
913
+ :arg inner_hits: If defined, each search hit will contain inner hits.
914
+ :arg max_children: Maximum number of child documents that match the
915
+ query allowed for a returned parent document. If the parent
916
+ document exceeds this limit, it is excluded from the search
917
+ results.
918
+ :arg min_children: Minimum number of child documents that match the
919
+ query required to match the query for a returned parent document.
920
+ If the parent document does not meet this limit, it is excluded
921
+ from the search results.
922
+ :arg score_mode: Indicates how scores for matching child documents
923
+ affect the root parent document’s relevance score. Defaults to
924
+ `'none'` if omitted.
925
+ :arg boost: Floating point number used to decrease or increase the
926
+ relevance scores of the query. Boost values are relative to the
927
+ default value of 1.0. A boost value between 0 and 1.0 decreases
928
+ the relevance score. A value greater than 1.0 increases the
929
+ relevance score. Defaults to `1` if omitted.
930
+ :arg _name:
931
+ """
932
+
933
+ name = "has_child"
934
+ _param_defs = {
935
+ "query": {"type": "query"},
936
+ }
937
+
938
+ def __init__(
939
+ self,
940
+ *,
941
+ query: Union[Query, "DefaultType"] = DEFAULT,
942
+ type: Union[str, "DefaultType"] = DEFAULT,
943
+ ignore_unmapped: Union[bool, "DefaultType"] = DEFAULT,
944
+ inner_hits: Union["types.InnerHits", Dict[str, Any], "DefaultType"] = DEFAULT,
945
+ max_children: Union[int, "DefaultType"] = DEFAULT,
946
+ min_children: Union[int, "DefaultType"] = DEFAULT,
947
+ score_mode: Union[
948
+ Literal["none", "avg", "sum", "max", "min"], "DefaultType"
949
+ ] = DEFAULT,
950
+ boost: Union[float, "DefaultType"] = DEFAULT,
951
+ _name: Union[str, "DefaultType"] = DEFAULT,
952
+ **kwargs: Any,
953
+ ):
954
+ super().__init__(
955
+ query=query,
956
+ type=type,
957
+ ignore_unmapped=ignore_unmapped,
958
+ inner_hits=inner_hits,
959
+ max_children=max_children,
960
+ min_children=min_children,
961
+ score_mode=score_mode,
962
+ boost=boost,
963
+ _name=_name,
964
+ **kwargs,
965
+ )
966
+
967
+
968
+ class HasParent(Query):
969
+ """
970
+ Returns child documents whose joined parent document matches a
971
+ provided query.
972
+
973
+ :arg parent_type: (required) Name of the parent relationship mapped
974
+ for the `join` field.
975
+ :arg query: (required) Query you wish to run on parent documents of
976
+ the `parent_type` field. If a parent document matches the search,
977
+ the query returns its child documents.
978
+ :arg ignore_unmapped: Indicates whether to ignore an unmapped
979
+ `parent_type` and not return any documents instead of an error.
980
+ You can use this parameter to query multiple indices that may not
981
+ contain the `parent_type`.
982
+ :arg inner_hits: If defined, each search hit will contain inner hits.
983
+ :arg score: Indicates whether the relevance score of a matching parent
984
+ document is aggregated into its child documents.
985
+ :arg boost: Floating point number used to decrease or increase the
986
+ relevance scores of the query. Boost values are relative to the
987
+ default value of 1.0. A boost value between 0 and 1.0 decreases
988
+ the relevance score. A value greater than 1.0 increases the
989
+ relevance score. Defaults to `1` if omitted.
990
+ :arg _name:
991
+ """
992
+
993
+ name = "has_parent"
994
+ _param_defs = {
995
+ "query": {"type": "query"},
996
+ }
997
+
998
+ def __init__(
999
+ self,
1000
+ *,
1001
+ parent_type: Union[str, "DefaultType"] = DEFAULT,
1002
+ query: Union[Query, "DefaultType"] = DEFAULT,
1003
+ ignore_unmapped: Union[bool, "DefaultType"] = DEFAULT,
1004
+ inner_hits: Union["types.InnerHits", Dict[str, Any], "DefaultType"] = DEFAULT,
1005
+ score: Union[bool, "DefaultType"] = DEFAULT,
1006
+ boost: Union[float, "DefaultType"] = DEFAULT,
1007
+ _name: Union[str, "DefaultType"] = DEFAULT,
1008
+ **kwargs: Any,
1009
+ ):
1010
+ super().__init__(
1011
+ parent_type=parent_type,
1012
+ query=query,
1013
+ ignore_unmapped=ignore_unmapped,
1014
+ inner_hits=inner_hits,
1015
+ score=score,
1016
+ boost=boost,
1017
+ _name=_name,
1018
+ **kwargs,
1019
+ )
1020
+
1021
+
1022
+ class Ids(Query):
1023
+ """
1024
+ Returns documents based on their IDs. This query uses document IDs
1025
+ stored in the `_id` field.
1026
+
1027
+ :arg values: An array of document IDs.
1028
+ :arg boost: Floating point number used to decrease or increase the
1029
+ relevance scores of the query. Boost values are relative to the
1030
+ default value of 1.0. A boost value between 0 and 1.0 decreases
1031
+ the relevance score. A value greater than 1.0 increases the
1032
+ relevance score. Defaults to `1` if omitted.
1033
+ :arg _name:
1034
+ """
1035
+
1036
+ name = "ids"
1037
+
1038
+ def __init__(
1039
+ self,
1040
+ *,
1041
+ values: Union[str, Sequence[str], "DefaultType"] = DEFAULT,
1042
+ boost: Union[float, "DefaultType"] = DEFAULT,
1043
+ _name: Union[str, "DefaultType"] = DEFAULT,
1044
+ **kwargs: Any,
1045
+ ):
1046
+ super().__init__(values=values, boost=boost, _name=_name, **kwargs)
1047
+
1048
+
1049
+ class Intervals(Query):
1050
+ """
1051
+ Returns documents based on the order and proximity of matching terms.
1052
+
1053
+ :arg _field: The field to use in this query.
1054
+ :arg _value: The query value for the field.
1055
+ """
1056
+
1057
+ name = "intervals"
1058
+
1059
+ def __init__(
1060
+ self,
1061
+ _field: Union[str, "InstrumentedField", "DefaultType"] = DEFAULT,
1062
+ _value: Union["types.IntervalsQuery", Dict[str, Any], "DefaultType"] = DEFAULT,
1063
+ **kwargs: Any,
1064
+ ):
1065
+ if _field is not DEFAULT:
1066
+ kwargs[str(_field)] = _value
1067
+ super().__init__(**kwargs)
1068
+
1069
+
1070
+ class Knn(Query):
1071
+ """
1072
+ Finds the k nearest vectors to a query vector, as measured by a
1073
+ similarity metric. knn query finds nearest vectors through approximate
1074
+ search on indexed dense_vectors.
1075
+
1076
+ :arg field: (required) The name of the vector field to search against
1077
+ :arg query_vector: The query vector
1078
+ :arg query_vector_builder: The query vector builder. You must provide
1079
+ a query_vector_builder or query_vector, but not both.
1080
+ :arg num_candidates: The number of nearest neighbor candidates to
1081
+ consider per shard
1082
+ :arg k: The final number of nearest neighbors to return as top hits
1083
+ :arg filter: Filters for the kNN search query
1084
+ :arg similarity: The minimum similarity for a vector to be considered
1085
+ a match
1086
+ :arg boost: Floating point number used to decrease or increase the
1087
+ relevance scores of the query. Boost values are relative to the
1088
+ default value of 1.0. A boost value between 0 and 1.0 decreases
1089
+ the relevance score. A value greater than 1.0 increases the
1090
+ relevance score. Defaults to `1` if omitted.
1091
+ :arg _name:
1092
+ """
1093
+
1094
+ name = "knn"
1095
+ _param_defs = {
1096
+ "filter": {"type": "query", "multi": True},
1097
+ }
1098
+
1099
+ def __init__(
1100
+ self,
1101
+ *,
1102
+ field: Union[str, "InstrumentedField", "DefaultType"] = DEFAULT,
1103
+ query_vector: Union[Sequence[float], "DefaultType"] = DEFAULT,
1104
+ query_vector_builder: Union[
1105
+ "types.QueryVectorBuilder", Dict[str, Any], "DefaultType"
1106
+ ] = DEFAULT,
1107
+ num_candidates: Union[int, "DefaultType"] = DEFAULT,
1108
+ k: Union[int, "DefaultType"] = DEFAULT,
1109
+ filter: Union[Query, Sequence[Query], "DefaultType"] = DEFAULT,
1110
+ similarity: Union[float, "DefaultType"] = DEFAULT,
1111
+ boost: Union[float, "DefaultType"] = DEFAULT,
1112
+ _name: Union[str, "DefaultType"] = DEFAULT,
1113
+ **kwargs: Any,
1114
+ ):
1115
+ super().__init__(
1116
+ field=field,
1117
+ query_vector=query_vector,
1118
+ query_vector_builder=query_vector_builder,
1119
+ num_candidates=num_candidates,
1120
+ k=k,
1121
+ filter=filter,
1122
+ similarity=similarity,
1123
+ boost=boost,
1124
+ _name=_name,
1125
+ **kwargs,
1126
+ )
1127
+
1128
+
1129
+ class Match(Query):
1130
+ """
1131
+ Returns documents that match a provided text, number, date or boolean
1132
+ value. The provided text is analyzed before matching.
1133
+
1134
+ :arg _field: The field to use in this query.
1135
+ :arg _value: The query value for the field.
1136
+ """
1137
+
1138
+ name = "match"
1139
+
1140
+ def __init__(
1141
+ self,
1142
+ _field: Union[str, "InstrumentedField", "DefaultType"] = DEFAULT,
1143
+ _value: Union["types.MatchQuery", Dict[str, Any], "DefaultType"] = DEFAULT,
1144
+ **kwargs: Any,
1145
+ ):
1146
+ if _field is not DEFAULT:
1147
+ kwargs[str(_field)] = _value
1148
+ super().__init__(**kwargs)
1149
+
1150
+
1151
+ class MatchAll(Query):
1152
+ """
1153
+ Matches all documents, giving them all a `_score` of 1.0.
1154
+
1155
+ :arg boost: Floating point number used to decrease or increase the
1156
+ relevance scores of the query. Boost values are relative to the
1157
+ default value of 1.0. A boost value between 0 and 1.0 decreases
1158
+ the relevance score. A value greater than 1.0 increases the
1159
+ relevance score. Defaults to `1` if omitted.
1160
+ :arg _name:
1161
+ """
1162
+
1163
+ name = "match_all"
1164
+
1165
+ def __init__(
1166
+ self,
1167
+ *,
1168
+ boost: Union[float, "DefaultType"] = DEFAULT,
1169
+ _name: Union[str, "DefaultType"] = DEFAULT,
1170
+ **kwargs: Any,
1171
+ ):
1172
+ super().__init__(boost=boost, _name=_name, **kwargs)
1173
+
1174
+ def __add__(self, other: "Query") -> "Query":
1175
+ return other._clone()
1176
+
1177
+ __and__ = __rand__ = __radd__ = __add__
1178
+
1179
+ def __or__(self, other: "Query") -> "MatchAll":
1180
+ return self
1181
+
1182
+ __ror__ = __or__
1183
+
1184
+ def __invert__(self) -> "MatchNone":
1185
+ return MatchNone()
1186
+
1187
+
1188
+ EMPTY_QUERY = MatchAll()
1189
+
1190
+
1191
+ class MatchBoolPrefix(Query):
1192
+ """
1193
+ Analyzes its input and constructs a `bool` query from the terms. Each
1194
+ term except the last is used in a `term` query. The last term is used
1195
+ in a prefix query.
1196
+
1197
+ :arg _field: The field to use in this query.
1198
+ :arg _value: The query value for the field.
1199
+ """
1200
+
1201
+ name = "match_bool_prefix"
1202
+
1203
+ def __init__(
1204
+ self,
1205
+ _field: Union[str, "InstrumentedField", "DefaultType"] = DEFAULT,
1206
+ _value: Union[
1207
+ "types.MatchBoolPrefixQuery", Dict[str, Any], "DefaultType"
1208
+ ] = DEFAULT,
1209
+ **kwargs: Any,
1210
+ ):
1211
+ if _field is not DEFAULT:
1212
+ kwargs[str(_field)] = _value
1213
+ super().__init__(**kwargs)
1214
+
1215
+
1216
+ class MatchNone(Query):
1217
+ """
1218
+ Matches no documents.
1219
+
1220
+ :arg boost: Floating point number used to decrease or increase the
1221
+ relevance scores of the query. Boost values are relative to the
1222
+ default value of 1.0. A boost value between 0 and 1.0 decreases
1223
+ the relevance score. A value greater than 1.0 increases the
1224
+ relevance score. Defaults to `1` if omitted.
1225
+ :arg _name:
1226
+ """
1227
+
1228
+ name = "match_none"
1229
+
1230
+ def __init__(
1231
+ self,
1232
+ *,
1233
+ boost: Union[float, "DefaultType"] = DEFAULT,
1234
+ _name: Union[str, "DefaultType"] = DEFAULT,
1235
+ **kwargs: Any,
1236
+ ):
1237
+ super().__init__(boost=boost, _name=_name, **kwargs)
1238
+
1239
+ def __add__(self, other: "Query") -> "MatchNone":
1240
+ return self
1241
+
1242
+ __and__ = __rand__ = __radd__ = __add__
1243
+
1244
+ def __or__(self, other: "Query") -> "Query":
1245
+ return other._clone()
1246
+
1247
+ __ror__ = __or__
1248
+
1249
+ def __invert__(self) -> MatchAll:
1250
+ return MatchAll()
1251
+
1252
+
1253
+ class MatchPhrase(Query):
1254
+ """
1255
+ Analyzes the text and creates a phrase query out of the analyzed text.
1256
+
1257
+ :arg _field: The field to use in this query.
1258
+ :arg _value: The query value for the field.
1259
+ """
1260
+
1261
+ name = "match_phrase"
1262
+
1263
+ def __init__(
1264
+ self,
1265
+ _field: Union[str, "InstrumentedField", "DefaultType"] = DEFAULT,
1266
+ _value: Union[
1267
+ "types.MatchPhraseQuery", Dict[str, Any], "DefaultType"
1268
+ ] = DEFAULT,
1269
+ **kwargs: Any,
1270
+ ):
1271
+ if _field is not DEFAULT:
1272
+ kwargs[str(_field)] = _value
1273
+ super().__init__(**kwargs)
1274
+
1275
+
1276
+ class MatchPhrasePrefix(Query):
1277
+ """
1278
+ Returns documents that contain the words of a provided text, in the
1279
+ same order as provided. The last term of the provided text is treated
1280
+ as a prefix, matching any words that begin with that term.
1281
+
1282
+ :arg _field: The field to use in this query.
1283
+ :arg _value: The query value for the field.
1284
+ """
1285
+
1286
+ name = "match_phrase_prefix"
1287
+
1288
+ def __init__(
1289
+ self,
1290
+ _field: Union[str, "InstrumentedField", "DefaultType"] = DEFAULT,
1291
+ _value: Union[
1292
+ "types.MatchPhrasePrefixQuery", Dict[str, Any], "DefaultType"
1293
+ ] = DEFAULT,
1294
+ **kwargs: Any,
1295
+ ):
1296
+ if _field is not DEFAULT:
1297
+ kwargs[str(_field)] = _value
1298
+ super().__init__(**kwargs)
1299
+
1300
+
1301
+ class MoreLikeThis(Query):
1302
+ """
1303
+ Returns documents that are "like" a given set of documents.
1304
+
1305
+ :arg like: (required) Specifies free form text and/or a single or
1306
+ multiple documents for which you want to find similar documents.
1307
+ :arg analyzer: The analyzer that is used to analyze the free form
1308
+ text. Defaults to the analyzer associated with the first field in
1309
+ fields.
1310
+ :arg boost_terms: Each term in the formed query could be further
1311
+ boosted by their tf-idf score. This sets the boost factor to use
1312
+ when using this feature. Defaults to deactivated (0).
1313
+ :arg fail_on_unsupported_field: Controls whether the query should fail
1314
+ (throw an exception) if any of the specified fields are not of the
1315
+ supported types (`text` or `keyword`). Defaults to `True` if
1316
+ omitted.
1317
+ :arg fields: A list of fields to fetch and analyze the text from.
1318
+ Defaults to the `index.query.default_field` index setting, which
1319
+ has a default value of `*`.
1320
+ :arg include: Specifies whether the input documents should also be
1321
+ included in the search results returned.
1322
+ :arg max_doc_freq: The maximum document frequency above which the
1323
+ terms are ignored from the input document.
1324
+ :arg max_query_terms: The maximum number of query terms that can be
1325
+ selected. Defaults to `25` if omitted.
1326
+ :arg max_word_length: The maximum word length above which the terms
1327
+ are ignored. Defaults to unbounded (`0`).
1328
+ :arg min_doc_freq: The minimum document frequency below which the
1329
+ terms are ignored from the input document. Defaults to `5` if
1330
+ omitted.
1331
+ :arg minimum_should_match: After the disjunctive query has been
1332
+ formed, this parameter controls the number of terms that must
1333
+ match.
1334
+ :arg min_term_freq: The minimum term frequency below which the terms
1335
+ are ignored from the input document. Defaults to `2` if omitted.
1336
+ :arg min_word_length: The minimum word length below which the terms
1337
+ are ignored.
1338
+ :arg routing:
1339
+ :arg stop_words: An array of stop words. Any word in this set is
1340
+ ignored.
1341
+ :arg unlike: Used in combination with `like` to exclude documents that
1342
+ match a set of terms.
1343
+ :arg version:
1344
+ :arg version_type: Defaults to `'internal'` if omitted.
1345
+ :arg boost: Floating point number used to decrease or increase the
1346
+ relevance scores of the query. Boost values are relative to the
1347
+ default value of 1.0. A boost value between 0 and 1.0 decreases
1348
+ the relevance score. A value greater than 1.0 increases the
1349
+ relevance score. Defaults to `1` if omitted.
1350
+ :arg _name:
1351
+ """
1352
+
1353
+ name = "more_like_this"
1354
+
1355
+ def __init__(
1356
+ self,
1357
+ *,
1358
+ like: Union[
1359
+ Union[str, "types.LikeDocument"],
1360
+ Sequence[Union[str, "types.LikeDocument"]],
1361
+ Dict[str, Any],
1362
+ "DefaultType",
1363
+ ] = DEFAULT,
1364
+ analyzer: Union[str, "DefaultType"] = DEFAULT,
1365
+ boost_terms: Union[float, "DefaultType"] = DEFAULT,
1366
+ fail_on_unsupported_field: Union[bool, "DefaultType"] = DEFAULT,
1367
+ fields: Union[
1368
+ Sequence[Union[str, "InstrumentedField"]], "DefaultType"
1369
+ ] = DEFAULT,
1370
+ include: Union[bool, "DefaultType"] = DEFAULT,
1371
+ max_doc_freq: Union[int, "DefaultType"] = DEFAULT,
1372
+ max_query_terms: Union[int, "DefaultType"] = DEFAULT,
1373
+ max_word_length: Union[int, "DefaultType"] = DEFAULT,
1374
+ min_doc_freq: Union[int, "DefaultType"] = DEFAULT,
1375
+ minimum_should_match: Union[int, str, "DefaultType"] = DEFAULT,
1376
+ min_term_freq: Union[int, "DefaultType"] = DEFAULT,
1377
+ min_word_length: Union[int, "DefaultType"] = DEFAULT,
1378
+ routing: Union[str, "DefaultType"] = DEFAULT,
1379
+ stop_words: Union[str, Sequence[str], "DefaultType"] = DEFAULT,
1380
+ unlike: Union[
1381
+ Union[str, "types.LikeDocument"],
1382
+ Sequence[Union[str, "types.LikeDocument"]],
1383
+ Dict[str, Any],
1384
+ "DefaultType",
1385
+ ] = DEFAULT,
1386
+ version: Union[int, "DefaultType"] = DEFAULT,
1387
+ version_type: Union[
1388
+ Literal["internal", "external", "external_gte", "force"], "DefaultType"
1389
+ ] = DEFAULT,
1390
+ boost: Union[float, "DefaultType"] = DEFAULT,
1391
+ _name: Union[str, "DefaultType"] = DEFAULT,
1392
+ **kwargs: Any,
1393
+ ):
1394
+ super().__init__(
1395
+ like=like,
1396
+ analyzer=analyzer,
1397
+ boost_terms=boost_terms,
1398
+ fail_on_unsupported_field=fail_on_unsupported_field,
1399
+ fields=fields,
1400
+ include=include,
1401
+ max_doc_freq=max_doc_freq,
1402
+ max_query_terms=max_query_terms,
1403
+ max_word_length=max_word_length,
1404
+ min_doc_freq=min_doc_freq,
1405
+ minimum_should_match=minimum_should_match,
1406
+ min_term_freq=min_term_freq,
1407
+ min_word_length=min_word_length,
1408
+ routing=routing,
1409
+ stop_words=stop_words,
1410
+ unlike=unlike,
1411
+ version=version,
1412
+ version_type=version_type,
1413
+ boost=boost,
1414
+ _name=_name,
1415
+ **kwargs,
1416
+ )
1417
+
1418
+
1419
+ class MultiMatch(Query):
1420
+ """
1421
+ Enables you to search for a provided text, number, date or boolean
1422
+ value across multiple fields. The provided text is analyzed before
1423
+ matching.
1424
+
1425
+ :arg query: (required) Text, number, boolean value or date you wish to
1426
+ find in the provided field.
1427
+ :arg analyzer: Analyzer used to convert the text in the query value
1428
+ into tokens.
1429
+ :arg auto_generate_synonyms_phrase_query: If `true`, match phrase
1430
+ queries are automatically created for multi-term synonyms.
1431
+ Defaults to `True` if omitted.
1432
+ :arg cutoff_frequency:
1433
+ :arg fields: The fields to be queried. Defaults to the
1434
+ `index.query.default_field` index settings, which in turn defaults
1435
+ to `*`.
1436
+ :arg fuzziness: Maximum edit distance allowed for matching.
1437
+ :arg fuzzy_rewrite: Method used to rewrite the query.
1438
+ :arg fuzzy_transpositions: If `true`, edits for fuzzy matching include
1439
+ transpositions of two adjacent characters (for example, `ab` to
1440
+ `ba`). Can be applied to the term subqueries constructed for all
1441
+ terms but the final term. Defaults to `True` if omitted.
1442
+ :arg lenient: If `true`, format-based errors, such as providing a text
1443
+ query value for a numeric field, are ignored.
1444
+ :arg max_expansions: Maximum number of terms to which the query will
1445
+ expand. Defaults to `50` if omitted.
1446
+ :arg minimum_should_match: Minimum number of clauses that must match
1447
+ for a document to be returned.
1448
+ :arg operator: Boolean logic used to interpret text in the query
1449
+ value. Defaults to `'or'` if omitted.
1450
+ :arg prefix_length: Number of beginning characters left unchanged for
1451
+ fuzzy matching.
1452
+ :arg slop: Maximum number of positions allowed between matching
1453
+ tokens.
1454
+ :arg tie_breaker: Determines how scores for each per-term blended
1455
+ query and scores across groups are combined.
1456
+ :arg type: How `the` multi_match query is executed internally.
1457
+ Defaults to `'best_fields'` if omitted.
1458
+ :arg zero_terms_query: Indicates whether no documents are returned if
1459
+ the `analyzer` removes all tokens, such as when using a `stop`
1460
+ filter. Defaults to `'none'` if omitted.
1461
+ :arg boost: Floating point number used to decrease or increase the
1462
+ relevance scores of the query. Boost values are relative to the
1463
+ default value of 1.0. A boost value between 0 and 1.0 decreases
1464
+ the relevance score. A value greater than 1.0 increases the
1465
+ relevance score. Defaults to `1` if omitted.
1466
+ :arg _name:
1467
+ """
1468
+
1469
+ name = "multi_match"
1470
+
1471
+ def __init__(
1472
+ self,
1473
+ *,
1474
+ query: Union[str, "DefaultType"] = DEFAULT,
1475
+ analyzer: Union[str, "DefaultType"] = DEFAULT,
1476
+ auto_generate_synonyms_phrase_query: Union[bool, "DefaultType"] = DEFAULT,
1477
+ cutoff_frequency: Union[float, "DefaultType"] = DEFAULT,
1478
+ fields: Union[
1479
+ Union[str, "InstrumentedField"],
1480
+ Sequence[Union[str, "InstrumentedField"]],
1481
+ "DefaultType",
1482
+ ] = DEFAULT,
1483
+ fuzziness: Union[str, int, "DefaultType"] = DEFAULT,
1484
+ fuzzy_rewrite: Union[str, "DefaultType"] = DEFAULT,
1485
+ fuzzy_transpositions: Union[bool, "DefaultType"] = DEFAULT,
1486
+ lenient: Union[bool, "DefaultType"] = DEFAULT,
1487
+ max_expansions: Union[int, "DefaultType"] = DEFAULT,
1488
+ minimum_should_match: Union[int, str, "DefaultType"] = DEFAULT,
1489
+ operator: Union[Literal["and", "or"], "DefaultType"] = DEFAULT,
1490
+ prefix_length: Union[int, "DefaultType"] = DEFAULT,
1491
+ slop: Union[int, "DefaultType"] = DEFAULT,
1492
+ tie_breaker: Union[float, "DefaultType"] = DEFAULT,
1493
+ type: Union[
1494
+ Literal[
1495
+ "best_fields",
1496
+ "most_fields",
1497
+ "cross_fields",
1498
+ "phrase",
1499
+ "phrase_prefix",
1500
+ "bool_prefix",
1501
+ ],
1502
+ "DefaultType",
1503
+ ] = DEFAULT,
1504
+ zero_terms_query: Union[Literal["all", "none"], "DefaultType"] = DEFAULT,
1505
+ boost: Union[float, "DefaultType"] = DEFAULT,
1506
+ _name: Union[str, "DefaultType"] = DEFAULT,
1507
+ **kwargs: Any,
1508
+ ):
1509
+ super().__init__(
1510
+ query=query,
1511
+ analyzer=analyzer,
1512
+ auto_generate_synonyms_phrase_query=auto_generate_synonyms_phrase_query,
1513
+ cutoff_frequency=cutoff_frequency,
1514
+ fields=fields,
1515
+ fuzziness=fuzziness,
1516
+ fuzzy_rewrite=fuzzy_rewrite,
1517
+ fuzzy_transpositions=fuzzy_transpositions,
1518
+ lenient=lenient,
1519
+ max_expansions=max_expansions,
1520
+ minimum_should_match=minimum_should_match,
1521
+ operator=operator,
1522
+ prefix_length=prefix_length,
1523
+ slop=slop,
1524
+ tie_breaker=tie_breaker,
1525
+ type=type,
1526
+ zero_terms_query=zero_terms_query,
1527
+ boost=boost,
1528
+ _name=_name,
1529
+ **kwargs,
1530
+ )
1531
+
1532
+
1533
+ class Nested(Query):
1534
+ """
1535
+ Wraps another query to search nested fields. If an object matches the
1536
+ search, the nested query returns the root parent document.
1537
+
1538
+ :arg path: (required) Path to the nested object you wish to search.
1539
+ :arg query: (required) Query you wish to run on nested objects in the
1540
+ path.
1541
+ :arg ignore_unmapped: Indicates whether to ignore an unmapped path and
1542
+ not return any documents instead of an error.
1543
+ :arg inner_hits: If defined, each search hit will contain inner hits.
1544
+ :arg score_mode: How scores for matching child objects affect the root
1545
+ parent document’s relevance score. Defaults to `'avg'` if omitted.
1546
+ :arg boost: Floating point number used to decrease or increase the
1547
+ relevance scores of the query. Boost values are relative to the
1548
+ default value of 1.0. A boost value between 0 and 1.0 decreases
1549
+ the relevance score. A value greater than 1.0 increases the
1550
+ relevance score. Defaults to `1` if omitted.
1551
+ :arg _name:
1552
+ """
1553
+
1554
+ name = "nested"
1555
+ _param_defs = {
1556
+ "query": {"type": "query"},
1557
+ }
1558
+
1559
+ def __init__(
1560
+ self,
1561
+ *,
1562
+ path: Union[str, "InstrumentedField", "DefaultType"] = DEFAULT,
1563
+ query: Union[Query, "DefaultType"] = DEFAULT,
1564
+ ignore_unmapped: Union[bool, "DefaultType"] = DEFAULT,
1565
+ inner_hits: Union["types.InnerHits", Dict[str, Any], "DefaultType"] = DEFAULT,
1566
+ score_mode: Union[
1567
+ Literal["none", "avg", "sum", "max", "min"], "DefaultType"
1568
+ ] = DEFAULT,
1569
+ boost: Union[float, "DefaultType"] = DEFAULT,
1570
+ _name: Union[str, "DefaultType"] = DEFAULT,
1571
+ **kwargs: Any,
1572
+ ):
1573
+ super().__init__(
1574
+ path=path,
1575
+ query=query,
1576
+ ignore_unmapped=ignore_unmapped,
1577
+ inner_hits=inner_hits,
1578
+ score_mode=score_mode,
1579
+ boost=boost,
1580
+ _name=_name,
1581
+ **kwargs,
1582
+ )
1583
+
1584
+
1585
+ class ParentId(Query):
1586
+ """
1587
+ Returns child documents joined to a specific parent document.
1588
+
1589
+ :arg id: ID of the parent document.
1590
+ :arg ignore_unmapped: Indicates whether to ignore an unmapped `type`
1591
+ and not return any documents instead of an error.
1592
+ :arg type: Name of the child relationship mapped for the `join` field.
1593
+ :arg boost: Floating point number used to decrease or increase the
1594
+ relevance scores of the query. Boost values are relative to the
1595
+ default value of 1.0. A boost value between 0 and 1.0 decreases
1596
+ the relevance score. A value greater than 1.0 increases the
1597
+ relevance score. Defaults to `1` if omitted.
1598
+ :arg _name:
1599
+ """
1600
+
1601
+ name = "parent_id"
1602
+
1603
+ def __init__(
1604
+ self,
1605
+ *,
1606
+ id: Union[str, "DefaultType"] = DEFAULT,
1607
+ ignore_unmapped: Union[bool, "DefaultType"] = DEFAULT,
1608
+ type: Union[str, "DefaultType"] = DEFAULT,
1609
+ boost: Union[float, "DefaultType"] = DEFAULT,
1610
+ _name: Union[str, "DefaultType"] = DEFAULT,
1611
+ **kwargs: Any,
1612
+ ):
1613
+ super().__init__(
1614
+ id=id,
1615
+ ignore_unmapped=ignore_unmapped,
1616
+ type=type,
1617
+ boost=boost,
1618
+ _name=_name,
1619
+ **kwargs,
1620
+ )
1621
+
1622
+
1623
+ class Percolate(Query):
1624
+ """
1625
+ Matches queries stored in an index.
1626
+
1627
+ :arg field: (required) Field that holds the indexed queries. The field
1628
+ must use the `percolator` mapping type.
1629
+ :arg document: The source of the document being percolated.
1630
+ :arg documents: An array of sources of the documents being percolated.
1631
+ :arg id: The ID of a stored document to percolate.
1632
+ :arg index: The index of a stored document to percolate.
1633
+ :arg name: The suffix used for the `_percolator_document_slot` field
1634
+ when multiple `percolate` queries are specified.
1635
+ :arg preference: Preference used to fetch document to percolate.
1636
+ :arg routing: Routing used to fetch document to percolate.
1637
+ :arg version: The expected version of a stored document to percolate.
1638
+ :arg boost: Floating point number used to decrease or increase the
1639
+ relevance scores of the query. Boost values are relative to the
1640
+ default value of 1.0. A boost value between 0 and 1.0 decreases
1641
+ the relevance score. A value greater than 1.0 increases the
1642
+ relevance score. Defaults to `1` if omitted.
1643
+ :arg _name:
1644
+ """
1645
+
1646
+ name = "percolate"
1647
+
1648
+ def __init__(
1649
+ self,
1650
+ *,
1651
+ field: Union[str, "InstrumentedField", "DefaultType"] = DEFAULT,
1652
+ document: Any = DEFAULT,
1653
+ documents: Union[Sequence[Any], "DefaultType"] = DEFAULT,
1654
+ id: Union[str, "DefaultType"] = DEFAULT,
1655
+ index: Union[str, "DefaultType"] = DEFAULT,
1656
+ name: Union[str, "DefaultType"] = DEFAULT,
1657
+ preference: Union[str, "DefaultType"] = DEFAULT,
1658
+ routing: Union[str, "DefaultType"] = DEFAULT,
1659
+ version: Union[int, "DefaultType"] = DEFAULT,
1660
+ boost: Union[float, "DefaultType"] = DEFAULT,
1661
+ _name: Union[str, "DefaultType"] = DEFAULT,
1662
+ **kwargs: Any,
1663
+ ):
1664
+ super().__init__(
1665
+ field=field,
1666
+ document=document,
1667
+ documents=documents,
1668
+ id=id,
1669
+ index=index,
1670
+ name=name,
1671
+ preference=preference,
1672
+ routing=routing,
1673
+ version=version,
1674
+ boost=boost,
1675
+ _name=_name,
1676
+ **kwargs,
1677
+ )
1678
+
1679
+
1680
+ class Pinned(Query):
1681
+ """
1682
+ Promotes selected documents to rank higher than those matching a given
1683
+ query.
1684
+
1685
+ :arg organic: (required) Any choice of query used to rank documents
1686
+ which will be ranked below the "pinned" documents.
1687
+ :arg ids: Document IDs listed in the order they are to appear in
1688
+ results. Required if `docs` is not specified.
1689
+ :arg docs: Documents listed in the order they are to appear in
1690
+ results. Required if `ids` is not specified.
1691
+ :arg boost: Floating point number used to decrease or increase the
1692
+ relevance scores of the query. Boost values are relative to the
1693
+ default value of 1.0. A boost value between 0 and 1.0 decreases
1694
+ the relevance score. A value greater than 1.0 increases the
1695
+ relevance score. Defaults to `1` if omitted.
1696
+ :arg _name:
1697
+ """
1698
+
1699
+ name = "pinned"
1700
+ _param_defs = {
1701
+ "organic": {"type": "query"},
1702
+ }
1703
+
1704
+ def __init__(
1705
+ self,
1706
+ *,
1707
+ organic: Union[Query, "DefaultType"] = DEFAULT,
1708
+ ids: Union[Sequence[str], "DefaultType"] = DEFAULT,
1709
+ docs: Union[
1710
+ Sequence["types.PinnedDoc"], Sequence[Dict[str, Any]], "DefaultType"
1711
+ ] = DEFAULT,
1712
+ boost: Union[float, "DefaultType"] = DEFAULT,
1713
+ _name: Union[str, "DefaultType"] = DEFAULT,
1714
+ **kwargs: Any,
1715
+ ):
1716
+ super().__init__(
1717
+ organic=organic, ids=ids, docs=docs, boost=boost, _name=_name, **kwargs
1718
+ )
1719
+
1720
+
1721
+ class Prefix(Query):
1722
+ """
1723
+ Returns documents that contain a specific prefix in a provided field.
1724
+
1725
+ :arg _field: The field to use in this query.
1726
+ :arg _value: The query value for the field.
1727
+ """
1728
+
1729
+ name = "prefix"
1730
+
1731
+ def __init__(
1732
+ self,
1733
+ _field: Union[str, "InstrumentedField", "DefaultType"] = DEFAULT,
1734
+ _value: Union["types.PrefixQuery", Dict[str, Any], "DefaultType"] = DEFAULT,
1735
+ **kwargs: Any,
1736
+ ):
1737
+ if _field is not DEFAULT:
1738
+ kwargs[str(_field)] = _value
1739
+ super().__init__(**kwargs)
1740
+
1741
+
1742
+ class QueryString(Query):
1743
+ """
1744
+ Returns documents based on a provided query string, using a parser
1745
+ with a strict syntax.
1746
+
1747
+ :arg query: (required) Query string you wish to parse and use for
1748
+ search.
1749
+ :arg allow_leading_wildcard: If `true`, the wildcard characters `*`
1750
+ and `?` are allowed as the first character of the query string.
1751
+ Defaults to `True` if omitted.
1752
+ :arg analyzer: Analyzer used to convert text in the query string into
1753
+ tokens.
1754
+ :arg analyze_wildcard: If `true`, the query attempts to analyze
1755
+ wildcard terms in the query string.
1756
+ :arg auto_generate_synonyms_phrase_query: If `true`, match phrase
1757
+ queries are automatically created for multi-term synonyms.
1758
+ Defaults to `True` if omitted.
1759
+ :arg default_field: Default field to search if no field is provided in
1760
+ the query string. Supports wildcards (`*`). Defaults to the
1761
+ `index.query.default_field` index setting, which has a default
1762
+ value of `*`.
1763
+ :arg default_operator: Default boolean logic used to interpret text in
1764
+ the query string if no operators are specified. Defaults to `'or'`
1765
+ if omitted.
1766
+ :arg enable_position_increments: If `true`, enable position increments
1767
+ in queries constructed from a `query_string` search. Defaults to
1768
+ `True` if omitted.
1769
+ :arg escape:
1770
+ :arg fields: Array of fields to search. Supports wildcards (`*`).
1771
+ :arg fuzziness: Maximum edit distance allowed for fuzzy matching.
1772
+ :arg fuzzy_max_expansions: Maximum number of terms to which the query
1773
+ expands for fuzzy matching. Defaults to `50` if omitted.
1774
+ :arg fuzzy_prefix_length: Number of beginning characters left
1775
+ unchanged for fuzzy matching.
1776
+ :arg fuzzy_rewrite: Method used to rewrite the query.
1777
+ :arg fuzzy_transpositions: If `true`, edits for fuzzy matching include
1778
+ transpositions of two adjacent characters (for example, `ab` to
1779
+ `ba`). Defaults to `True` if omitted.
1780
+ :arg lenient: If `true`, format-based errors, such as providing a text
1781
+ value for a numeric field, are ignored.
1782
+ :arg max_determinized_states: Maximum number of automaton states
1783
+ required for the query. Defaults to `10000` if omitted.
1784
+ :arg minimum_should_match: Minimum number of clauses that must match
1785
+ for a document to be returned.
1786
+ :arg phrase_slop: Maximum number of positions allowed between matching
1787
+ tokens for phrases.
1788
+ :arg quote_analyzer: Analyzer used to convert quoted text in the query
1789
+ string into tokens. For quoted text, this parameter overrides the
1790
+ analyzer specified in the `analyzer` parameter.
1791
+ :arg quote_field_suffix: Suffix appended to quoted text in the query
1792
+ string. You can use this suffix to use a different analysis method
1793
+ for exact matches.
1794
+ :arg rewrite: Method used to rewrite the query.
1795
+ :arg tie_breaker: How to combine the queries generated from the
1796
+ individual search terms in the resulting `dis_max` query.
1797
+ :arg time_zone: Coordinated Universal Time (UTC) offset or IANA time
1798
+ zone used to convert date values in the query string to UTC.
1799
+ :arg type: Determines how the query matches and scores documents.
1800
+ Defaults to `'best_fields'` if omitted.
1801
+ :arg boost: Floating point number used to decrease or increase the
1802
+ relevance scores of the query. Boost values are relative to the
1803
+ default value of 1.0. A boost value between 0 and 1.0 decreases
1804
+ the relevance score. A value greater than 1.0 increases the
1805
+ relevance score. Defaults to `1` if omitted.
1806
+ :arg _name:
1807
+ """
1808
+
1809
+ name = "query_string"
1810
+
1811
+ def __init__(
1812
+ self,
1813
+ *,
1814
+ query: Union[str, "DefaultType"] = DEFAULT,
1815
+ allow_leading_wildcard: Union[bool, "DefaultType"] = DEFAULT,
1816
+ analyzer: Union[str, "DefaultType"] = DEFAULT,
1817
+ analyze_wildcard: Union[bool, "DefaultType"] = DEFAULT,
1818
+ auto_generate_synonyms_phrase_query: Union[bool, "DefaultType"] = DEFAULT,
1819
+ default_field: Union[str, "InstrumentedField", "DefaultType"] = DEFAULT,
1820
+ default_operator: Union[Literal["and", "or"], "DefaultType"] = DEFAULT,
1821
+ enable_position_increments: Union[bool, "DefaultType"] = DEFAULT,
1822
+ escape: Union[bool, "DefaultType"] = DEFAULT,
1823
+ fields: Union[
1824
+ Sequence[Union[str, "InstrumentedField"]], "DefaultType"
1825
+ ] = DEFAULT,
1826
+ fuzziness: Union[str, int, "DefaultType"] = DEFAULT,
1827
+ fuzzy_max_expansions: Union[int, "DefaultType"] = DEFAULT,
1828
+ fuzzy_prefix_length: Union[int, "DefaultType"] = DEFAULT,
1829
+ fuzzy_rewrite: Union[str, "DefaultType"] = DEFAULT,
1830
+ fuzzy_transpositions: Union[bool, "DefaultType"] = DEFAULT,
1831
+ lenient: Union[bool, "DefaultType"] = DEFAULT,
1832
+ max_determinized_states: Union[int, "DefaultType"] = DEFAULT,
1833
+ minimum_should_match: Union[int, str, "DefaultType"] = DEFAULT,
1834
+ phrase_slop: Union[float, "DefaultType"] = DEFAULT,
1835
+ quote_analyzer: Union[str, "DefaultType"] = DEFAULT,
1836
+ quote_field_suffix: Union[str, "DefaultType"] = DEFAULT,
1837
+ rewrite: Union[str, "DefaultType"] = DEFAULT,
1838
+ tie_breaker: Union[float, "DefaultType"] = DEFAULT,
1839
+ time_zone: Union[str, "DefaultType"] = DEFAULT,
1840
+ type: Union[
1841
+ Literal[
1842
+ "best_fields",
1843
+ "most_fields",
1844
+ "cross_fields",
1845
+ "phrase",
1846
+ "phrase_prefix",
1847
+ "bool_prefix",
1848
+ ],
1849
+ "DefaultType",
1850
+ ] = DEFAULT,
1851
+ boost: Union[float, "DefaultType"] = DEFAULT,
1852
+ _name: Union[str, "DefaultType"] = DEFAULT,
1853
+ **kwargs: Any,
1854
+ ):
1855
+ super().__init__(
1856
+ query=query,
1857
+ allow_leading_wildcard=allow_leading_wildcard,
1858
+ analyzer=analyzer,
1859
+ analyze_wildcard=analyze_wildcard,
1860
+ auto_generate_synonyms_phrase_query=auto_generate_synonyms_phrase_query,
1861
+ default_field=default_field,
1862
+ default_operator=default_operator,
1863
+ enable_position_increments=enable_position_increments,
1864
+ escape=escape,
1865
+ fields=fields,
1866
+ fuzziness=fuzziness,
1867
+ fuzzy_max_expansions=fuzzy_max_expansions,
1868
+ fuzzy_prefix_length=fuzzy_prefix_length,
1869
+ fuzzy_rewrite=fuzzy_rewrite,
1870
+ fuzzy_transpositions=fuzzy_transpositions,
1871
+ lenient=lenient,
1872
+ max_determinized_states=max_determinized_states,
1873
+ minimum_should_match=minimum_should_match,
1874
+ phrase_slop=phrase_slop,
1875
+ quote_analyzer=quote_analyzer,
1876
+ quote_field_suffix=quote_field_suffix,
1877
+ rewrite=rewrite,
1878
+ tie_breaker=tie_breaker,
1879
+ time_zone=time_zone,
1880
+ type=type,
1881
+ boost=boost,
1882
+ _name=_name,
1883
+ **kwargs,
1884
+ )
1885
+
1886
+
1887
+ class Range(Query):
1888
+ """
1889
+ Returns documents that contain terms within a provided range.
1890
+
1891
+ :arg _field: The field to use in this query.
1892
+ :arg _value: The query value for the field.
1893
+ """
1894
+
1895
+ name = "range"
1896
+
1897
+ def __init__(
1898
+ self,
1899
+ _field: Union[str, "InstrumentedField", "DefaultType"] = DEFAULT,
1900
+ _value: Union["wrappers.Range[Any]", Dict[str, Any], "DefaultType"] = DEFAULT,
1901
+ **kwargs: Any,
1902
+ ):
1903
+ if _field is not DEFAULT:
1904
+ kwargs[str(_field)] = _value
1905
+ super().__init__(**kwargs)
1906
+
1907
+
1908
+ class RankFeature(Query):
1909
+ """
1910
+ Boosts the relevance score of documents based on the numeric value of
1911
+ a `rank_feature` or `rank_features` field.
1912
+
1913
+ :arg field: (required) `rank_feature` or `rank_features` field used to
1914
+ boost relevance scores.
1915
+ :arg saturation: Saturation function used to boost relevance scores
1916
+ based on the value of the rank feature `field`.
1917
+ :arg log: Logarithmic function used to boost relevance scores based on
1918
+ the value of the rank feature `field`.
1919
+ :arg linear: Linear function used to boost relevance scores based on
1920
+ the value of the rank feature `field`.
1921
+ :arg sigmoid: Sigmoid function used to boost relevance scores based on
1922
+ the value of the rank feature `field`.
1923
+ :arg boost: Floating point number used to decrease or increase the
1924
+ relevance scores of the query. Boost values are relative to the
1925
+ default value of 1.0. A boost value between 0 and 1.0 decreases
1926
+ the relevance score. A value greater than 1.0 increases the
1927
+ relevance score. Defaults to `1` if omitted.
1928
+ :arg _name:
1929
+ """
1930
+
1931
+ name = "rank_feature"
1932
+
1933
+ def __init__(
1934
+ self,
1935
+ *,
1936
+ field: Union[str, "InstrumentedField", "DefaultType"] = DEFAULT,
1937
+ saturation: Union[
1938
+ "types.RankFeatureFunctionSaturation", Dict[str, Any], "DefaultType"
1939
+ ] = DEFAULT,
1940
+ log: Union[
1941
+ "types.RankFeatureFunctionLogarithm", Dict[str, Any], "DefaultType"
1942
+ ] = DEFAULT,
1943
+ linear: Union[
1944
+ "types.RankFeatureFunctionLinear", Dict[str, Any], "DefaultType"
1945
+ ] = DEFAULT,
1946
+ sigmoid: Union[
1947
+ "types.RankFeatureFunctionSigmoid", Dict[str, Any], "DefaultType"
1948
+ ] = DEFAULT,
1949
+ boost: Union[float, "DefaultType"] = DEFAULT,
1950
+ _name: Union[str, "DefaultType"] = DEFAULT,
1951
+ **kwargs: Any,
1952
+ ):
1953
+ super().__init__(
1954
+ field=field,
1955
+ saturation=saturation,
1956
+ log=log,
1957
+ linear=linear,
1958
+ sigmoid=sigmoid,
1959
+ boost=boost,
1960
+ _name=_name,
1961
+ **kwargs,
1962
+ )
1963
+
1964
+
1965
+ class Regexp(Query):
1966
+ """
1967
+ Returns documents that contain terms matching a regular expression.
1968
+
1969
+ :arg _field: The field to use in this query.
1970
+ :arg _value: The query value for the field.
1971
+ """
1972
+
1973
+ name = "regexp"
1974
+
1975
+ def __init__(
1976
+ self,
1977
+ _field: Union[str, "InstrumentedField", "DefaultType"] = DEFAULT,
1978
+ _value: Union["types.RegexpQuery", Dict[str, Any], "DefaultType"] = DEFAULT,
1979
+ **kwargs: Any,
1980
+ ):
1981
+ if _field is not DEFAULT:
1982
+ kwargs[str(_field)] = _value
1983
+ super().__init__(**kwargs)
1984
+
1985
+
1986
+ class Rule(Query):
1987
+ """
1988
+ :arg organic: (required)
1989
+ :arg ruleset_ids: (required)
1990
+ :arg match_criteria: (required)
1991
+ :arg boost: Floating point number used to decrease or increase the
1992
+ relevance scores of the query. Boost values are relative to the
1993
+ default value of 1.0. A boost value between 0 and 1.0 decreases
1994
+ the relevance score. A value greater than 1.0 increases the
1995
+ relevance score. Defaults to `1` if omitted.
1996
+ :arg _name:
1997
+ """
1998
+
1999
+ name = "rule"
2000
+ _param_defs = {
2001
+ "organic": {"type": "query"},
2002
+ }
2003
+
2004
+ def __init__(
2005
+ self,
2006
+ *,
2007
+ organic: Union[Query, "DefaultType"] = DEFAULT,
2008
+ ruleset_ids: Union[Sequence[str], "DefaultType"] = DEFAULT,
2009
+ match_criteria: Any = DEFAULT,
2010
+ boost: Union[float, "DefaultType"] = DEFAULT,
2011
+ _name: Union[str, "DefaultType"] = DEFAULT,
2012
+ **kwargs: Any,
2013
+ ):
2014
+ super().__init__(
2015
+ organic=organic,
2016
+ ruleset_ids=ruleset_ids,
2017
+ match_criteria=match_criteria,
2018
+ boost=boost,
2019
+ _name=_name,
2020
+ **kwargs,
2021
+ )
2022
+
2023
+
2024
+ class Script(Query):
2025
+ """
2026
+ Filters documents based on a provided script. The script query is
2027
+ typically used in a filter context.
2028
+
2029
+ :arg script: (required) Contains a script to run as a query. This
2030
+ script must return a boolean value, `true` or `false`.
2031
+ :arg boost: Floating point number used to decrease or increase the
2032
+ relevance scores of the query. Boost values are relative to the
2033
+ default value of 1.0. A boost value between 0 and 1.0 decreases
2034
+ the relevance score. A value greater than 1.0 increases the
2035
+ relevance score. Defaults to `1` if omitted.
2036
+ :arg _name:
2037
+ """
2038
+
2039
+ name = "script"
2040
+
2041
+ def __init__(
2042
+ self,
2043
+ *,
2044
+ script: Union["types.Script", Dict[str, Any], "DefaultType"] = DEFAULT,
2045
+ boost: Union[float, "DefaultType"] = DEFAULT,
2046
+ _name: Union[str, "DefaultType"] = DEFAULT,
2047
+ **kwargs: Any,
2048
+ ):
2049
+ super().__init__(script=script, boost=boost, _name=_name, **kwargs)
2050
+
2051
+
2052
+ class ScriptScore(Query):
2053
+ """
2054
+ Uses a script to provide a custom score for returned documents.
2055
+
2056
+ :arg query: (required) Query used to return documents.
2057
+ :arg script: (required) Script used to compute the score of documents
2058
+ returned by the query. Important: final relevance scores from the
2059
+ `script_score` query cannot be negative.
2060
+ :arg min_score: Documents with a score lower than this floating point
2061
+ number are excluded from the search results.
2062
+ :arg boost: Floating point number used to decrease or increase the
2063
+ relevance scores of the query. Boost values are relative to the
2064
+ default value of 1.0. A boost value between 0 and 1.0 decreases
2065
+ the relevance score. A value greater than 1.0 increases the
2066
+ relevance score. Defaults to `1` if omitted.
2067
+ :arg _name:
2068
+ """
2069
+
2070
+ name = "script_score"
2071
+ _param_defs = {
2072
+ "query": {"type": "query"},
2073
+ }
2074
+
2075
+ def __init__(
2076
+ self,
2077
+ *,
2078
+ query: Union[Query, "DefaultType"] = DEFAULT,
2079
+ script: Union["types.Script", Dict[str, Any], "DefaultType"] = DEFAULT,
2080
+ min_score: Union[float, "DefaultType"] = DEFAULT,
2081
+ boost: Union[float, "DefaultType"] = DEFAULT,
2082
+ _name: Union[str, "DefaultType"] = DEFAULT,
2083
+ **kwargs: Any,
2084
+ ):
2085
+ super().__init__(
2086
+ query=query,
2087
+ script=script,
2088
+ min_score=min_score,
2089
+ boost=boost,
2090
+ _name=_name,
2091
+ **kwargs,
2092
+ )
2093
+
2094
+
2095
+ class Semantic(Query):
2096
+ """
2097
+ A semantic query to semantic_text field types
2098
+
2099
+ :arg field: (required) The field to query, which must be a
2100
+ semantic_text field type
2101
+ :arg query: (required) The query text
2102
+ :arg boost: Floating point number used to decrease or increase the
2103
+ relevance scores of the query. Boost values are relative to the
2104
+ default value of 1.0. A boost value between 0 and 1.0 decreases
2105
+ the relevance score. A value greater than 1.0 increases the
2106
+ relevance score. Defaults to `1` if omitted.
2107
+ :arg _name:
2108
+ """
2109
+
2110
+ name = "semantic"
2111
+
2112
+ def __init__(
2113
+ self,
2114
+ *,
2115
+ field: Union[str, "DefaultType"] = DEFAULT,
2116
+ query: Union[str, "DefaultType"] = DEFAULT,
2117
+ boost: Union[float, "DefaultType"] = DEFAULT,
2118
+ _name: Union[str, "DefaultType"] = DEFAULT,
2119
+ **kwargs: Any,
2120
+ ):
2121
+ super().__init__(field=field, query=query, boost=boost, _name=_name, **kwargs)
2122
+
2123
+
2124
+ class Shape(Query):
2125
+ """
2126
+ Queries documents that contain fields indexed using the `shape` type.
2127
+
2128
+ :arg _field: The field to use in this query.
2129
+ :arg _value: The query value for the field.
2130
+ :arg ignore_unmapped: When set to `true` the query ignores an unmapped
2131
+ field and will not match any documents.
2132
+ :arg boost: Floating point number used to decrease or increase the
2133
+ relevance scores of the query. Boost values are relative to the
2134
+ default value of 1.0. A boost value between 0 and 1.0 decreases
2135
+ the relevance score. A value greater than 1.0 increases the
2136
+ relevance score. Defaults to `1` if omitted.
2137
+ :arg _name:
2138
+ """
2139
+
2140
+ name = "shape"
2141
+
2142
+ def __init__(
2143
+ self,
2144
+ _field: Union[str, "InstrumentedField", "DefaultType"] = DEFAULT,
2145
+ _value: Union["types.ShapeFieldQuery", Dict[str, Any], "DefaultType"] = DEFAULT,
2146
+ *,
2147
+ ignore_unmapped: Union[bool, "DefaultType"] = DEFAULT,
2148
+ boost: Union[float, "DefaultType"] = DEFAULT,
2149
+ _name: Union[str, "DefaultType"] = DEFAULT,
2150
+ **kwargs: Any,
2151
+ ):
2152
+ if _field is not DEFAULT:
2153
+ kwargs[str(_field)] = _value
2154
+ super().__init__(
2155
+ ignore_unmapped=ignore_unmapped, boost=boost, _name=_name, **kwargs
2156
+ )
2157
+
2158
+
2159
+ class SimpleQueryString(Query):
2160
+ """
2161
+ Returns documents based on a provided query string, using a parser
2162
+ with a limited but fault-tolerant syntax.
2163
+
2164
+ :arg query: (required) Query string in the simple query string syntax
2165
+ you wish to parse and use for search.
2166
+ :arg analyzer: Analyzer used to convert text in the query string into
2167
+ tokens.
2168
+ :arg analyze_wildcard: If `true`, the query attempts to analyze
2169
+ wildcard terms in the query string.
2170
+ :arg auto_generate_synonyms_phrase_query: If `true`, the parser
2171
+ creates a match_phrase query for each multi-position token.
2172
+ Defaults to `True` if omitted.
2173
+ :arg default_operator: Default boolean logic used to interpret text in
2174
+ the query string if no operators are specified. Defaults to `'or'`
2175
+ if omitted.
2176
+ :arg fields: Array of fields you wish to search. Accepts wildcard
2177
+ expressions. You also can boost relevance scores for matches to
2178
+ particular fields using a caret (`^`) notation. Defaults to the
2179
+ `index.query.default_field index` setting, which has a default
2180
+ value of `*`.
2181
+ :arg flags: List of enabled operators for the simple query string
2182
+ syntax. Defaults to `ALL` if omitted.
2183
+ :arg fuzzy_max_expansions: Maximum number of terms to which the query
2184
+ expands for fuzzy matching. Defaults to `50` if omitted.
2185
+ :arg fuzzy_prefix_length: Number of beginning characters left
2186
+ unchanged for fuzzy matching.
2187
+ :arg fuzzy_transpositions: If `true`, edits for fuzzy matching include
2188
+ transpositions of two adjacent characters (for example, `ab` to
2189
+ `ba`).
2190
+ :arg lenient: If `true`, format-based errors, such as providing a text
2191
+ value for a numeric field, are ignored.
2192
+ :arg minimum_should_match: Minimum number of clauses that must match
2193
+ for a document to be returned.
2194
+ :arg quote_field_suffix: Suffix appended to quoted text in the query
2195
+ string.
2196
+ :arg boost: Floating point number used to decrease or increase the
2197
+ relevance scores of the query. Boost values are relative to the
2198
+ default value of 1.0. A boost value between 0 and 1.0 decreases
2199
+ the relevance score. A value greater than 1.0 increases the
2200
+ relevance score. Defaults to `1` if omitted.
2201
+ :arg _name:
2202
+ """
2203
+
2204
+ name = "simple_query_string"
2205
+
2206
+ def __init__(
2207
+ self,
2208
+ *,
2209
+ query: Union[str, "DefaultType"] = DEFAULT,
2210
+ analyzer: Union[str, "DefaultType"] = DEFAULT,
2211
+ analyze_wildcard: Union[bool, "DefaultType"] = DEFAULT,
2212
+ auto_generate_synonyms_phrase_query: Union[bool, "DefaultType"] = DEFAULT,
2213
+ default_operator: Union[Literal["and", "or"], "DefaultType"] = DEFAULT,
2214
+ fields: Union[
2215
+ Sequence[Union[str, "InstrumentedField"]], "DefaultType"
2216
+ ] = DEFAULT,
2217
+ flags: Union[
2218
+ "types.PipeSeparatedFlags", Dict[str, Any], "DefaultType"
2219
+ ] = DEFAULT,
2220
+ fuzzy_max_expansions: Union[int, "DefaultType"] = DEFAULT,
2221
+ fuzzy_prefix_length: Union[int, "DefaultType"] = DEFAULT,
2222
+ fuzzy_transpositions: Union[bool, "DefaultType"] = DEFAULT,
2223
+ lenient: Union[bool, "DefaultType"] = DEFAULT,
2224
+ minimum_should_match: Union[int, str, "DefaultType"] = DEFAULT,
2225
+ quote_field_suffix: Union[str, "DefaultType"] = DEFAULT,
2226
+ boost: Union[float, "DefaultType"] = DEFAULT,
2227
+ _name: Union[str, "DefaultType"] = DEFAULT,
2228
+ **kwargs: Any,
2229
+ ):
2230
+ super().__init__(
2231
+ query=query,
2232
+ analyzer=analyzer,
2233
+ analyze_wildcard=analyze_wildcard,
2234
+ auto_generate_synonyms_phrase_query=auto_generate_synonyms_phrase_query,
2235
+ default_operator=default_operator,
2236
+ fields=fields,
2237
+ flags=flags,
2238
+ fuzzy_max_expansions=fuzzy_max_expansions,
2239
+ fuzzy_prefix_length=fuzzy_prefix_length,
2240
+ fuzzy_transpositions=fuzzy_transpositions,
2241
+ lenient=lenient,
2242
+ minimum_should_match=minimum_should_match,
2243
+ quote_field_suffix=quote_field_suffix,
2244
+ boost=boost,
2245
+ _name=_name,
2246
+ **kwargs,
2247
+ )
2248
+
2249
+
2250
+ class SpanContaining(Query):
2251
+ """
2252
+ Returns matches which enclose another span query.
2253
+
2254
+ :arg big: (required) Can be any span query. Matching spans from `big`
2255
+ that contain matches from `little` are returned.
2256
+ :arg little: (required) Can be any span query. Matching spans from
2257
+ `big` that contain matches from `little` are returned.
2258
+ :arg boost: Floating point number used to decrease or increase the
2259
+ relevance scores of the query. Boost values are relative to the
2260
+ default value of 1.0. A boost value between 0 and 1.0 decreases
2261
+ the relevance score. A value greater than 1.0 increases the
2262
+ relevance score. Defaults to `1` if omitted.
2263
+ :arg _name:
2264
+ """
2265
+
2266
+ name = "span_containing"
2267
+
2268
+ def __init__(
2269
+ self,
2270
+ *,
2271
+ big: Union["types.SpanQuery", Dict[str, Any], "DefaultType"] = DEFAULT,
2272
+ little: Union["types.SpanQuery", Dict[str, Any], "DefaultType"] = DEFAULT,
2273
+ boost: Union[float, "DefaultType"] = DEFAULT,
2274
+ _name: Union[str, "DefaultType"] = DEFAULT,
2275
+ **kwargs: Any,
2276
+ ):
2277
+ super().__init__(big=big, little=little, boost=boost, _name=_name, **kwargs)
2278
+
2279
+
2280
+ class SpanFieldMasking(Query):
2281
+ """
2282
+ Wrapper to allow span queries to participate in composite single-field
2283
+ span queries by _lying_ about their search field.
2284
+
2285
+ :arg field: (required)
2286
+ :arg query: (required)
2287
+ :arg boost: Floating point number used to decrease or increase the
2288
+ relevance scores of the query. Boost values are relative to the
2289
+ default value of 1.0. A boost value between 0 and 1.0 decreases
2290
+ the relevance score. A value greater than 1.0 increases the
2291
+ relevance score. Defaults to `1` if omitted.
2292
+ :arg _name:
2293
+ """
2294
+
2295
+ name = "span_field_masking"
2296
+
2297
+ def __init__(
2298
+ self,
2299
+ *,
2300
+ field: Union[str, "InstrumentedField", "DefaultType"] = DEFAULT,
2301
+ query: Union["types.SpanQuery", Dict[str, Any], "DefaultType"] = DEFAULT,
2302
+ boost: Union[float, "DefaultType"] = DEFAULT,
2303
+ _name: Union[str, "DefaultType"] = DEFAULT,
2304
+ **kwargs: Any,
2305
+ ):
2306
+ super().__init__(field=field, query=query, boost=boost, _name=_name, **kwargs)
2307
+
2308
+
2309
+ class SpanFirst(Query):
2310
+ """
2311
+ Matches spans near the beginning of a field.
2312
+
2313
+ :arg end: (required) Controls the maximum end position permitted in a
2314
+ match.
2315
+ :arg match: (required) Can be any other span type query.
2316
+ :arg boost: Floating point number used to decrease or increase the
2317
+ relevance scores of the query. Boost values are relative to the
2318
+ default value of 1.0. A boost value between 0 and 1.0 decreases
2319
+ the relevance score. A value greater than 1.0 increases the
2320
+ relevance score. Defaults to `1` if omitted.
2321
+ :arg _name:
2322
+ """
2323
+
2324
+ name = "span_first"
2325
+
2326
+ def __init__(
2327
+ self,
2328
+ *,
2329
+ end: Union[int, "DefaultType"] = DEFAULT,
2330
+ match: Union["types.SpanQuery", Dict[str, Any], "DefaultType"] = DEFAULT,
2331
+ boost: Union[float, "DefaultType"] = DEFAULT,
2332
+ _name: Union[str, "DefaultType"] = DEFAULT,
2333
+ **kwargs: Any,
2334
+ ):
2335
+ super().__init__(end=end, match=match, boost=boost, _name=_name, **kwargs)
2336
+
2337
+
2338
+ class SpanMulti(Query):
2339
+ """
2340
+ Allows you to wrap a multi term query (one of `wildcard`, `fuzzy`,
2341
+ `prefix`, `range`, or `regexp` query) as a `span` query, so it can be
2342
+ nested.
2343
+
2344
+ :arg match: (required) Should be a multi term query (one of
2345
+ `wildcard`, `fuzzy`, `prefix`, `range`, or `regexp` query).
2346
+ :arg boost: Floating point number used to decrease or increase the
2347
+ relevance scores of the query. Boost values are relative to the
2348
+ default value of 1.0. A boost value between 0 and 1.0 decreases
2349
+ the relevance score. A value greater than 1.0 increases the
2350
+ relevance score. Defaults to `1` if omitted.
2351
+ :arg _name:
2352
+ """
2353
+
2354
+ name = "span_multi"
2355
+ _param_defs = {
2356
+ "match": {"type": "query"},
2357
+ }
2358
+
2359
+ def __init__(
2360
+ self,
2361
+ *,
2362
+ match: Union[Query, "DefaultType"] = DEFAULT,
2363
+ boost: Union[float, "DefaultType"] = DEFAULT,
2364
+ _name: Union[str, "DefaultType"] = DEFAULT,
2365
+ **kwargs: Any,
2366
+ ):
2367
+ super().__init__(match=match, boost=boost, _name=_name, **kwargs)
2368
+
2369
+
2370
+ class SpanNear(Query):
2371
+ """
2372
+ Matches spans which are near one another. You can specify `slop`, the
2373
+ maximum number of intervening unmatched positions, as well as whether
2374
+ matches are required to be in-order.
2375
+
2376
+ :arg clauses: (required) Array of one or more other span type queries.
2377
+ :arg in_order: Controls whether matches are required to be in-order.
2378
+ :arg slop: Controls the maximum number of intervening unmatched
2379
+ positions permitted.
2380
+ :arg boost: Floating point number used to decrease or increase the
2381
+ relevance scores of the query. Boost values are relative to the
2382
+ default value of 1.0. A boost value between 0 and 1.0 decreases
2383
+ the relevance score. A value greater than 1.0 increases the
2384
+ relevance score. Defaults to `1` if omitted.
2385
+ :arg _name:
2386
+ """
2387
+
2388
+ name = "span_near"
2389
+
2390
+ def __init__(
2391
+ self,
2392
+ *,
2393
+ clauses: Union[
2394
+ Sequence["types.SpanQuery"], Sequence[Dict[str, Any]], "DefaultType"
2395
+ ] = DEFAULT,
2396
+ in_order: Union[bool, "DefaultType"] = DEFAULT,
2397
+ slop: Union[int, "DefaultType"] = DEFAULT,
2398
+ boost: Union[float, "DefaultType"] = DEFAULT,
2399
+ _name: Union[str, "DefaultType"] = DEFAULT,
2400
+ **kwargs: Any,
2401
+ ):
2402
+ super().__init__(
2403
+ clauses=clauses,
2404
+ in_order=in_order,
2405
+ slop=slop,
2406
+ boost=boost,
2407
+ _name=_name,
2408
+ **kwargs,
2409
+ )
2410
+
2411
+
2412
+ class SpanNot(Query):
2413
+ """
2414
+ Removes matches which overlap with another span query or which are
2415
+ within x tokens before (controlled by the parameter `pre`) or y tokens
2416
+ after (controlled by the parameter `post`) another span query.
2417
+
2418
+ :arg exclude: (required) Span query whose matches must not overlap
2419
+ those returned.
2420
+ :arg include: (required) Span query whose matches are filtered.
2421
+ :arg dist: The number of tokens from within the include span that
2422
+ can’t have overlap with the exclude span. Equivalent to setting
2423
+ both `pre` and `post`.
2424
+ :arg post: The number of tokens after the include span that can’t have
2425
+ overlap with the exclude span.
2426
+ :arg pre: The number of tokens before the include span that can’t have
2427
+ overlap with the exclude span.
2428
+ :arg boost: Floating point number used to decrease or increase the
2429
+ relevance scores of the query. Boost values are relative to the
2430
+ default value of 1.0. A boost value between 0 and 1.0 decreases
2431
+ the relevance score. A value greater than 1.0 increases the
2432
+ relevance score. Defaults to `1` if omitted.
2433
+ :arg _name:
2434
+ """
2435
+
2436
+ name = "span_not"
2437
+
2438
+ def __init__(
2439
+ self,
2440
+ *,
2441
+ exclude: Union["types.SpanQuery", Dict[str, Any], "DefaultType"] = DEFAULT,
2442
+ include: Union["types.SpanQuery", Dict[str, Any], "DefaultType"] = DEFAULT,
2443
+ dist: Union[int, "DefaultType"] = DEFAULT,
2444
+ post: Union[int, "DefaultType"] = DEFAULT,
2445
+ pre: Union[int, "DefaultType"] = DEFAULT,
2446
+ boost: Union[float, "DefaultType"] = DEFAULT,
2447
+ _name: Union[str, "DefaultType"] = DEFAULT,
2448
+ **kwargs: Any,
2449
+ ):
2450
+ super().__init__(
2451
+ exclude=exclude,
2452
+ include=include,
2453
+ dist=dist,
2454
+ post=post,
2455
+ pre=pre,
2456
+ boost=boost,
2457
+ _name=_name,
2458
+ **kwargs,
2459
+ )
2460
+
2461
+
2462
+ class SpanOr(Query):
2463
+ """
2464
+ Matches the union of its span clauses.
2465
+
2466
+ :arg clauses: (required) Array of one or more other span type queries.
2467
+ :arg boost: Floating point number used to decrease or increase the
2468
+ relevance scores of the query. Boost values are relative to the
2469
+ default value of 1.0. A boost value between 0 and 1.0 decreases
2470
+ the relevance score. A value greater than 1.0 increases the
2471
+ relevance score. Defaults to `1` if omitted.
2472
+ :arg _name:
2473
+ """
2474
+
2475
+ name = "span_or"
2476
+
2477
+ def __init__(
2478
+ self,
2479
+ *,
2480
+ clauses: Union[
2481
+ Sequence["types.SpanQuery"], Sequence[Dict[str, Any]], "DefaultType"
2482
+ ] = DEFAULT,
2483
+ boost: Union[float, "DefaultType"] = DEFAULT,
2484
+ _name: Union[str, "DefaultType"] = DEFAULT,
2485
+ **kwargs: Any,
2486
+ ):
2487
+ super().__init__(clauses=clauses, boost=boost, _name=_name, **kwargs)
2488
+
2489
+
2490
+ class SpanTerm(Query):
2491
+ """
2492
+ Matches spans containing a term.
2493
+
2494
+ :arg _field: The field to use in this query.
2495
+ :arg _value: The query value for the field.
2496
+ """
2497
+
2498
+ name = "span_term"
2499
+
2500
+ def __init__(
2501
+ self,
2502
+ _field: Union[str, "InstrumentedField", "DefaultType"] = DEFAULT,
2503
+ _value: Union["types.SpanTermQuery", Dict[str, Any], "DefaultType"] = DEFAULT,
2504
+ **kwargs: Any,
2505
+ ):
2506
+ if _field is not DEFAULT:
2507
+ kwargs[str(_field)] = _value
2508
+ super().__init__(**kwargs)
2509
+
2510
+
2511
+ class SpanWithin(Query):
2512
+ """
2513
+ Returns matches which are enclosed inside another span query.
2514
+
2515
+ :arg big: (required) Can be any span query. Matching spans from
2516
+ `little` that are enclosed within `big` are returned.
2517
+ :arg little: (required) Can be any span query. Matching spans from
2518
+ `little` that are enclosed within `big` are returned.
2519
+ :arg boost: Floating point number used to decrease or increase the
2520
+ relevance scores of the query. Boost values are relative to the
2521
+ default value of 1.0. A boost value between 0 and 1.0 decreases
2522
+ the relevance score. A value greater than 1.0 increases the
2523
+ relevance score. Defaults to `1` if omitted.
2524
+ :arg _name:
2525
+ """
2526
+
2527
+ name = "span_within"
2528
+
2529
+ def __init__(
2530
+ self,
2531
+ *,
2532
+ big: Union["types.SpanQuery", Dict[str, Any], "DefaultType"] = DEFAULT,
2533
+ little: Union["types.SpanQuery", Dict[str, Any], "DefaultType"] = DEFAULT,
2534
+ boost: Union[float, "DefaultType"] = DEFAULT,
2535
+ _name: Union[str, "DefaultType"] = DEFAULT,
2536
+ **kwargs: Any,
2537
+ ):
2538
+ super().__init__(big=big, little=little, boost=boost, _name=_name, **kwargs)
2539
+
2540
+
2541
+ class SparseVector(Query):
2542
+ """
2543
+ Using input query vectors or a natural language processing model to
2544
+ convert a query into a list of token-weight pairs, queries against a
2545
+ sparse vector field.
2546
+
2547
+ :arg field: (required) The name of the field that contains the token-
2548
+ weight pairs to be searched against. This field must be a mapped
2549
+ sparse_vector field.
2550
+ :arg query_vector: Dictionary of precomputed sparse vectors and their
2551
+ associated weights. Only one of inference_id or query_vector may
2552
+ be supplied in a request.
2553
+ :arg inference_id: The inference ID to use to convert the query text
2554
+ into token-weight pairs. It must be the same inference ID that was
2555
+ used to create the tokens from the input text. Only one of
2556
+ inference_id and query_vector is allowed. If inference_id is
2557
+ specified, query must also be specified. Only one of inference_id
2558
+ or query_vector may be supplied in a request.
2559
+ :arg query: The query text you want to use for search. If inference_id
2560
+ is specified, query must also be specified.
2561
+ :arg prune: Whether to perform pruning, omitting the non-significant
2562
+ tokens from the query to improve query performance. If prune is
2563
+ true but the pruning_config is not specified, pruning will occur
2564
+ but default values will be used. Default: false
2565
+ :arg pruning_config: Optional pruning configuration. If enabled, this
2566
+ will omit non-significant tokens from the query in order to
2567
+ improve query performance. This is only used if prune is set to
2568
+ true. If prune is set to true but pruning_config is not specified,
2569
+ default values will be used.
2570
+ :arg boost: Floating point number used to decrease or increase the
2571
+ relevance scores of the query. Boost values are relative to the
2572
+ default value of 1.0. A boost value between 0 and 1.0 decreases
2573
+ the relevance score. A value greater than 1.0 increases the
2574
+ relevance score. Defaults to `1` if omitted.
2575
+ :arg _name:
2576
+ """
2577
+
2578
+ name = "sparse_vector"
2579
+
2580
+ def __init__(
2581
+ self,
2582
+ *,
2583
+ field: Union[str, "InstrumentedField", "DefaultType"] = DEFAULT,
2584
+ query_vector: Union[Mapping[str, float], "DefaultType"] = DEFAULT,
2585
+ inference_id: Union[str, "DefaultType"] = DEFAULT,
2586
+ query: Union[str, "DefaultType"] = DEFAULT,
2587
+ prune: Union[bool, "DefaultType"] = DEFAULT,
2588
+ pruning_config: Union[
2589
+ "types.TokenPruningConfig", Dict[str, Any], "DefaultType"
2590
+ ] = DEFAULT,
2591
+ boost: Union[float, "DefaultType"] = DEFAULT,
2592
+ _name: Union[str, "DefaultType"] = DEFAULT,
2593
+ **kwargs: Any,
2594
+ ):
2595
+ super().__init__(
2596
+ field=field,
2597
+ query_vector=query_vector,
2598
+ inference_id=inference_id,
2599
+ query=query,
2600
+ prune=prune,
2601
+ pruning_config=pruning_config,
2602
+ boost=boost,
2603
+ _name=_name,
2604
+ **kwargs,
2605
+ )
2606
+
2607
+
2608
+ class Term(Query):
2609
+ """
2610
+ Returns documents that contain an exact term in a provided field. To
2611
+ return a document, the query term must exactly match the queried
2612
+ field's value, including whitespace and capitalization.
2613
+
2614
+ :arg _field: The field to use in this query.
2615
+ :arg _value: The query value for the field.
2616
+ """
2617
+
2618
+ name = "term"
2619
+
2620
+ def __init__(
2621
+ self,
2622
+ _field: Union[str, "InstrumentedField", "DefaultType"] = DEFAULT,
2623
+ _value: Union["types.TermQuery", Dict[str, Any], "DefaultType"] = DEFAULT,
2624
+ **kwargs: Any,
2625
+ ):
2626
+ if _field is not DEFAULT:
2627
+ kwargs[str(_field)] = _value
2628
+ super().__init__(**kwargs)
2629
+
2630
+
2631
+ class Terms(Query):
2632
+ """
2633
+ Returns documents that contain one or more exact terms in a provided
2634
+ field. To return a document, one or more terms must exactly match a
2635
+ field value, including whitespace and capitalization.
2636
+
2637
+ :arg _field: The field to use in this query.
2638
+ :arg _value: The query value for the field.
2639
+ :arg boost: Floating point number used to decrease or increase the
2640
+ relevance scores of the query. Boost values are relative to the
2641
+ default value of 1.0. A boost value between 0 and 1.0 decreases
2642
+ the relevance score. A value greater than 1.0 increases the
2643
+ relevance score. Defaults to `1` if omitted.
2644
+ :arg _name:
2645
+ """
2646
+
2647
+ name = "terms"
2648
+
2649
+ def __init__(
2650
+ self,
2651
+ _field: Union[str, "InstrumentedField", "DefaultType"] = DEFAULT,
2652
+ _value: Union[
2653
+ Sequence[Union[int, float, str, bool, None, Any]],
2654
+ "types.TermsLookup",
2655
+ Dict[str, Any],
2656
+ "DefaultType",
2657
+ ] = DEFAULT,
2658
+ *,
2659
+ boost: Union[float, "DefaultType"] = DEFAULT,
2660
+ _name: Union[str, "DefaultType"] = DEFAULT,
2661
+ **kwargs: Any,
2662
+ ):
2663
+ if _field is not DEFAULT:
2664
+ kwargs[str(_field)] = _value
2665
+ super().__init__(boost=boost, _name=_name, **kwargs)
2666
+
2667
+ def _setattr(self, name: str, value: Any) -> None:
2668
+ # here we convert any iterables that are not strings to lists
2669
+ if hasattr(value, "__iter__") and not isinstance(value, (str, list, dict)):
2670
+ value = list(value)
2671
+ super()._setattr(name, value)
2672
+
2673
+
2674
+ class TermsSet(Query):
2675
+ """
2676
+ Returns documents that contain a minimum number of exact terms in a
2677
+ provided field. To return a document, a required number of terms must
2678
+ exactly match the field values, including whitespace and
2679
+ capitalization.
2680
+
2681
+ :arg _field: The field to use in this query.
2682
+ :arg _value: The query value for the field.
2683
+ """
2684
+
2685
+ name = "terms_set"
2686
+
2687
+ def __init__(
2688
+ self,
2689
+ _field: Union[str, "InstrumentedField", "DefaultType"] = DEFAULT,
2690
+ _value: Union["types.TermsSetQuery", Dict[str, Any], "DefaultType"] = DEFAULT,
2691
+ **kwargs: Any,
2692
+ ):
2693
+ if _field is not DEFAULT:
2694
+ kwargs[str(_field)] = _value
2695
+ super().__init__(**kwargs)
2696
+
2697
+
2698
+ class TextExpansion(Query):
2699
+ """
2700
+ Uses a natural language processing model to convert the query text
2701
+ into a list of token-weight pairs which are then used in a query
2702
+ against a sparse vector or rank features field.
2703
+
2704
+ :arg _field: The field to use in this query.
2705
+ :arg _value: The query value for the field.
2706
+ """
2707
+
2708
+ name = "text_expansion"
2709
+
2710
+ def __init__(
2711
+ self,
2712
+ _field: Union[str, "InstrumentedField", "DefaultType"] = DEFAULT,
2713
+ _value: Union[
2714
+ "types.TextExpansionQuery", Dict[str, Any], "DefaultType"
2715
+ ] = DEFAULT,
2716
+ **kwargs: Any,
2717
+ ):
2718
+ if _field is not DEFAULT:
2719
+ kwargs[str(_field)] = _value
2720
+ super().__init__(**kwargs)
2721
+
2722
+
2723
+ class WeightedTokens(Query):
2724
+ """
2725
+ Supports returning text_expansion query results by sending in
2726
+ precomputed tokens with the query.
2727
+
2728
+ :arg _field: The field to use in this query.
2729
+ :arg _value: The query value for the field.
2730
+ """
2731
+
2732
+ name = "weighted_tokens"
2733
+
2734
+ def __init__(
2735
+ self,
2736
+ _field: Union[str, "InstrumentedField", "DefaultType"] = DEFAULT,
2737
+ _value: Union[
2738
+ "types.WeightedTokensQuery", Dict[str, Any], "DefaultType"
2739
+ ] = DEFAULT,
2740
+ **kwargs: Any,
2741
+ ):
2742
+ if _field is not DEFAULT:
2743
+ kwargs[str(_field)] = _value
2744
+ super().__init__(**kwargs)
2745
+
2746
+
2747
+ class Wildcard(Query):
2748
+ """
2749
+ Returns documents that contain terms matching a wildcard pattern.
2750
+
2751
+ :arg _field: The field to use in this query.
2752
+ :arg _value: The query value for the field.
2753
+ """
2754
+
2755
+ name = "wildcard"
2756
+
2757
+ def __init__(
2758
+ self,
2759
+ _field: Union[str, "InstrumentedField", "DefaultType"] = DEFAULT,
2760
+ _value: Union["types.WildcardQuery", Dict[str, Any], "DefaultType"] = DEFAULT,
2761
+ **kwargs: Any,
2762
+ ):
2763
+ if _field is not DEFAULT:
2764
+ kwargs[str(_field)] = _value
2765
+ super().__init__(**kwargs)
2766
+
2767
+
2768
+ class Wrapper(Query):
2769
+ """
2770
+ A query that accepts any other query as base64 encoded string.
2771
+
2772
+ :arg query: (required) A base64 encoded query. The binary data format
2773
+ can be any of JSON, YAML, CBOR or SMILE encodings
2774
+ :arg boost: Floating point number used to decrease or increase the
2775
+ relevance scores of the query. Boost values are relative to the
2776
+ default value of 1.0. A boost value between 0 and 1.0 decreases
2777
+ the relevance score. A value greater than 1.0 increases the
2778
+ relevance score. Defaults to `1` if omitted.
2779
+ :arg _name:
2780
+ """
2781
+
2782
+ name = "wrapper"
2783
+
2784
+ def __init__(
2785
+ self,
2786
+ *,
2787
+ query: Union[str, "DefaultType"] = DEFAULT,
2788
+ boost: Union[float, "DefaultType"] = DEFAULT,
2789
+ _name: Union[str, "DefaultType"] = DEFAULT,
2790
+ **kwargs: Any,
2791
+ ):
2792
+ super().__init__(query=query, boost=boost, _name=_name, **kwargs)
2793
+
2794
+
2795
+ class Type(Query):
2796
+ """
2797
+ :arg value: (required)
2798
+ :arg boost: Floating point number used to decrease or increase the
2799
+ relevance scores of the query. Boost values are relative to the
2800
+ default value of 1.0. A boost value between 0 and 1.0 decreases
2801
+ the relevance score. A value greater than 1.0 increases the
2802
+ relevance score. Defaults to `1` if omitted.
2803
+ :arg _name:
2804
+ """
2805
+
2806
+ name = "type"
2807
+
2808
+ def __init__(
2809
+ self,
2810
+ *,
2811
+ value: Union[str, "DefaultType"] = DEFAULT,
2812
+ boost: Union[float, "DefaultType"] = DEFAULT,
2813
+ _name: Union[str, "DefaultType"] = DEFAULT,
2814
+ **kwargs: Any,
2815
+ ):
2816
+ super().__init__(value=value, boost=boost, _name=_name, **kwargs)