elasticsearch 8.17.2__py3-none-any.whl → 8.18.1__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- elasticsearch/_async/client/__init__.py +174 -79
- elasticsearch/_async/client/_base.py +0 -1
- elasticsearch/_async/client/async_search.py +12 -8
- elasticsearch/_async/client/autoscaling.py +4 -4
- elasticsearch/_async/client/cat.py +26 -26
- elasticsearch/_async/client/ccr.py +186 -72
- elasticsearch/_async/client/cluster.py +38 -19
- elasticsearch/_async/client/connector.py +30 -30
- elasticsearch/_async/client/dangling_indices.py +3 -3
- elasticsearch/_async/client/enrich.py +26 -5
- elasticsearch/_async/client/eql.py +32 -4
- elasticsearch/_async/client/esql.py +62 -6
- elasticsearch/_async/client/features.py +12 -2
- elasticsearch/_async/client/fleet.py +8 -2
- elasticsearch/_async/client/graph.py +1 -1
- elasticsearch/_async/client/ilm.py +23 -22
- elasticsearch/_async/client/indices.py +424 -132
- elasticsearch/_async/client/inference.py +1906 -61
- elasticsearch/_async/client/ingest.py +32 -38
- elasticsearch/_async/client/license.py +51 -16
- elasticsearch/_async/client/logstash.py +3 -3
- elasticsearch/_async/client/migration.py +3 -3
- elasticsearch/_async/client/ml.py +144 -115
- elasticsearch/_async/client/monitoring.py +1 -1
- elasticsearch/_async/client/nodes.py +9 -27
- elasticsearch/_async/client/query_rules.py +8 -8
- elasticsearch/_async/client/rollup.py +8 -8
- elasticsearch/_async/client/search_application.py +13 -13
- elasticsearch/_async/client/searchable_snapshots.py +4 -4
- elasticsearch/_async/client/security.py +71 -71
- elasticsearch/_async/client/shutdown.py +3 -10
- elasticsearch/_async/client/simulate.py +6 -6
- elasticsearch/_async/client/slm.py +9 -9
- elasticsearch/_async/client/snapshot.py +13 -17
- elasticsearch/_async/client/sql.py +6 -6
- elasticsearch/_async/client/ssl.py +1 -1
- elasticsearch/_async/client/synonyms.py +7 -7
- elasticsearch/_async/client/tasks.py +3 -9
- elasticsearch/_async/client/text_structure.py +4 -4
- elasticsearch/_async/client/transform.py +30 -28
- elasticsearch/_async/client/watcher.py +22 -14
- elasticsearch/_async/client/xpack.py +2 -2
- elasticsearch/_async/helpers.py +0 -1
- elasticsearch/_sync/client/__init__.py +174 -79
- elasticsearch/_sync/client/_base.py +0 -1
- elasticsearch/_sync/client/async_search.py +12 -8
- elasticsearch/_sync/client/autoscaling.py +4 -4
- elasticsearch/_sync/client/cat.py +26 -26
- elasticsearch/_sync/client/ccr.py +186 -72
- elasticsearch/_sync/client/cluster.py +38 -19
- elasticsearch/_sync/client/connector.py +30 -30
- elasticsearch/_sync/client/dangling_indices.py +3 -3
- elasticsearch/_sync/client/enrich.py +26 -5
- elasticsearch/_sync/client/eql.py +32 -4
- elasticsearch/_sync/client/esql.py +62 -6
- elasticsearch/_sync/client/features.py +12 -2
- elasticsearch/_sync/client/fleet.py +8 -2
- elasticsearch/_sync/client/graph.py +1 -1
- elasticsearch/_sync/client/ilm.py +23 -22
- elasticsearch/_sync/client/indices.py +424 -132
- elasticsearch/_sync/client/inference.py +1906 -61
- elasticsearch/_sync/client/ingest.py +32 -38
- elasticsearch/_sync/client/license.py +51 -16
- elasticsearch/_sync/client/logstash.py +3 -3
- elasticsearch/_sync/client/migration.py +3 -3
- elasticsearch/_sync/client/ml.py +144 -115
- elasticsearch/_sync/client/monitoring.py +1 -1
- elasticsearch/_sync/client/nodes.py +9 -27
- elasticsearch/_sync/client/query_rules.py +8 -8
- elasticsearch/_sync/client/rollup.py +8 -8
- elasticsearch/_sync/client/search_application.py +13 -13
- elasticsearch/_sync/client/searchable_snapshots.py +4 -4
- elasticsearch/_sync/client/security.py +71 -71
- elasticsearch/_sync/client/shutdown.py +3 -10
- elasticsearch/_sync/client/simulate.py +6 -6
- elasticsearch/_sync/client/slm.py +9 -9
- elasticsearch/_sync/client/snapshot.py +13 -17
- elasticsearch/_sync/client/sql.py +6 -6
- elasticsearch/_sync/client/ssl.py +1 -1
- elasticsearch/_sync/client/synonyms.py +7 -7
- elasticsearch/_sync/client/tasks.py +3 -9
- elasticsearch/_sync/client/text_structure.py +4 -4
- elasticsearch/_sync/client/transform.py +30 -28
- elasticsearch/_sync/client/utils.py +0 -3
- elasticsearch/_sync/client/watcher.py +22 -14
- elasticsearch/_sync/client/xpack.py +2 -2
- elasticsearch/_version.py +1 -1
- elasticsearch/dsl/__init__.py +203 -0
- elasticsearch/dsl/_async/__init__.py +16 -0
- elasticsearch/dsl/_async/document.py +522 -0
- elasticsearch/dsl/_async/faceted_search.py +50 -0
- elasticsearch/dsl/_async/index.py +639 -0
- elasticsearch/dsl/_async/mapping.py +49 -0
- elasticsearch/dsl/_async/search.py +233 -0
- elasticsearch/dsl/_async/update_by_query.py +47 -0
- elasticsearch/dsl/_sync/__init__.py +16 -0
- elasticsearch/dsl/_sync/document.py +514 -0
- elasticsearch/dsl/_sync/faceted_search.py +50 -0
- elasticsearch/dsl/_sync/index.py +597 -0
- elasticsearch/dsl/_sync/mapping.py +49 -0
- elasticsearch/dsl/_sync/search.py +226 -0
- elasticsearch/dsl/_sync/update_by_query.py +45 -0
- elasticsearch/dsl/aggs.py +3730 -0
- elasticsearch/dsl/analysis.py +341 -0
- elasticsearch/dsl/async_connections.py +37 -0
- elasticsearch/dsl/connections.py +142 -0
- elasticsearch/dsl/document.py +20 -0
- elasticsearch/dsl/document_base.py +444 -0
- elasticsearch/dsl/exceptions.py +32 -0
- elasticsearch/dsl/faceted_search.py +28 -0
- elasticsearch/dsl/faceted_search_base.py +489 -0
- elasticsearch/dsl/field.py +4392 -0
- elasticsearch/dsl/function.py +180 -0
- elasticsearch/dsl/index.py +23 -0
- elasticsearch/dsl/index_base.py +178 -0
- elasticsearch/dsl/mapping.py +19 -0
- elasticsearch/dsl/mapping_base.py +219 -0
- elasticsearch/dsl/query.py +2822 -0
- elasticsearch/dsl/response/__init__.py +388 -0
- elasticsearch/dsl/response/aggs.py +100 -0
- elasticsearch/dsl/response/hit.py +53 -0
- elasticsearch/dsl/search.py +20 -0
- elasticsearch/dsl/search_base.py +1040 -0
- elasticsearch/dsl/serializer.py +34 -0
- elasticsearch/dsl/types.py +6509 -0
- elasticsearch/dsl/update_by_query.py +19 -0
- elasticsearch/dsl/update_by_query_base.py +149 -0
- elasticsearch/dsl/utils.py +687 -0
- elasticsearch/dsl/wrappers.py +119 -0
- {elasticsearch-8.17.2.dist-info → elasticsearch-8.18.1.dist-info}/METADATA +14 -2
- elasticsearch-8.18.1.dist-info/RECORD +163 -0
- elasticsearch-8.18.1.dist-info/licenses/LICENSE.txt +175 -0
- elasticsearch-8.18.1.dist-info/licenses/NOTICE.txt +559 -0
- elasticsearch-8.17.2.dist-info/RECORD +0 -119
- {elasticsearch-8.17.2.dist-info → elasticsearch-8.18.1.dist-info}/WHEEL +0 -0
- {elasticsearch-8.17.2.dist-info → elasticsearch-8.18.1.dist-info}/licenses/LICENSE +0 -0
- {elasticsearch-8.17.2.dist-info → elasticsearch-8.18.1.dist-info}/licenses/NOTICE +0 -0
|
@@ -0,0 +1,2822 @@
|
|
|
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 rescore_vector: Apply oversampling and rescoring to quantized
|
|
1087
|
+
vectors *
|
|
1088
|
+
:arg boost: Floating point number used to decrease or increase the
|
|
1089
|
+
relevance scores of the query. Boost values are relative to the
|
|
1090
|
+
default value of 1.0. A boost value between 0 and 1.0 decreases
|
|
1091
|
+
the relevance score. A value greater than 1.0 increases the
|
|
1092
|
+
relevance score. Defaults to `1` if omitted.
|
|
1093
|
+
:arg _name:
|
|
1094
|
+
"""
|
|
1095
|
+
|
|
1096
|
+
name = "knn"
|
|
1097
|
+
_param_defs = {
|
|
1098
|
+
"filter": {"type": "query", "multi": True},
|
|
1099
|
+
}
|
|
1100
|
+
|
|
1101
|
+
def __init__(
|
|
1102
|
+
self,
|
|
1103
|
+
*,
|
|
1104
|
+
field: Union[str, "InstrumentedField", "DefaultType"] = DEFAULT,
|
|
1105
|
+
query_vector: Union[Sequence[float], "DefaultType"] = DEFAULT,
|
|
1106
|
+
query_vector_builder: Union[
|
|
1107
|
+
"types.QueryVectorBuilder", Dict[str, Any], "DefaultType"
|
|
1108
|
+
] = DEFAULT,
|
|
1109
|
+
num_candidates: Union[int, "DefaultType"] = DEFAULT,
|
|
1110
|
+
k: Union[int, "DefaultType"] = DEFAULT,
|
|
1111
|
+
filter: Union[Query, Sequence[Query], "DefaultType"] = DEFAULT,
|
|
1112
|
+
similarity: Union[float, "DefaultType"] = DEFAULT,
|
|
1113
|
+
rescore_vector: Union[
|
|
1114
|
+
"types.RescoreVector", Dict[str, Any], "DefaultType"
|
|
1115
|
+
] = DEFAULT,
|
|
1116
|
+
boost: Union[float, "DefaultType"] = DEFAULT,
|
|
1117
|
+
_name: Union[str, "DefaultType"] = DEFAULT,
|
|
1118
|
+
**kwargs: Any,
|
|
1119
|
+
):
|
|
1120
|
+
super().__init__(
|
|
1121
|
+
field=field,
|
|
1122
|
+
query_vector=query_vector,
|
|
1123
|
+
query_vector_builder=query_vector_builder,
|
|
1124
|
+
num_candidates=num_candidates,
|
|
1125
|
+
k=k,
|
|
1126
|
+
filter=filter,
|
|
1127
|
+
similarity=similarity,
|
|
1128
|
+
rescore_vector=rescore_vector,
|
|
1129
|
+
boost=boost,
|
|
1130
|
+
_name=_name,
|
|
1131
|
+
**kwargs,
|
|
1132
|
+
)
|
|
1133
|
+
|
|
1134
|
+
|
|
1135
|
+
class Match(Query):
|
|
1136
|
+
"""
|
|
1137
|
+
Returns documents that match a provided text, number, date or boolean
|
|
1138
|
+
value. The provided text is analyzed before matching.
|
|
1139
|
+
|
|
1140
|
+
:arg _field: The field to use in this query.
|
|
1141
|
+
:arg _value: The query value for the field.
|
|
1142
|
+
"""
|
|
1143
|
+
|
|
1144
|
+
name = "match"
|
|
1145
|
+
|
|
1146
|
+
def __init__(
|
|
1147
|
+
self,
|
|
1148
|
+
_field: Union[str, "InstrumentedField", "DefaultType"] = DEFAULT,
|
|
1149
|
+
_value: Union["types.MatchQuery", Dict[str, Any], "DefaultType"] = DEFAULT,
|
|
1150
|
+
**kwargs: Any,
|
|
1151
|
+
):
|
|
1152
|
+
if _field is not DEFAULT:
|
|
1153
|
+
kwargs[str(_field)] = _value
|
|
1154
|
+
super().__init__(**kwargs)
|
|
1155
|
+
|
|
1156
|
+
|
|
1157
|
+
class MatchAll(Query):
|
|
1158
|
+
"""
|
|
1159
|
+
Matches all documents, giving them all a `_score` of 1.0.
|
|
1160
|
+
|
|
1161
|
+
:arg boost: Floating point number used to decrease or increase the
|
|
1162
|
+
relevance scores of the query. Boost values are relative to the
|
|
1163
|
+
default value of 1.0. A boost value between 0 and 1.0 decreases
|
|
1164
|
+
the relevance score. A value greater than 1.0 increases the
|
|
1165
|
+
relevance score. Defaults to `1` if omitted.
|
|
1166
|
+
:arg _name:
|
|
1167
|
+
"""
|
|
1168
|
+
|
|
1169
|
+
name = "match_all"
|
|
1170
|
+
|
|
1171
|
+
def __init__(
|
|
1172
|
+
self,
|
|
1173
|
+
*,
|
|
1174
|
+
boost: Union[float, "DefaultType"] = DEFAULT,
|
|
1175
|
+
_name: Union[str, "DefaultType"] = DEFAULT,
|
|
1176
|
+
**kwargs: Any,
|
|
1177
|
+
):
|
|
1178
|
+
super().__init__(boost=boost, _name=_name, **kwargs)
|
|
1179
|
+
|
|
1180
|
+
def __add__(self, other: "Query") -> "Query":
|
|
1181
|
+
return other._clone()
|
|
1182
|
+
|
|
1183
|
+
__and__ = __rand__ = __radd__ = __add__
|
|
1184
|
+
|
|
1185
|
+
def __or__(self, other: "Query") -> "MatchAll":
|
|
1186
|
+
return self
|
|
1187
|
+
|
|
1188
|
+
__ror__ = __or__
|
|
1189
|
+
|
|
1190
|
+
def __invert__(self) -> "MatchNone":
|
|
1191
|
+
return MatchNone()
|
|
1192
|
+
|
|
1193
|
+
|
|
1194
|
+
EMPTY_QUERY = MatchAll()
|
|
1195
|
+
|
|
1196
|
+
|
|
1197
|
+
class MatchBoolPrefix(Query):
|
|
1198
|
+
"""
|
|
1199
|
+
Analyzes its input and constructs a `bool` query from the terms. Each
|
|
1200
|
+
term except the last is used in a `term` query. The last term is used
|
|
1201
|
+
in a prefix query.
|
|
1202
|
+
|
|
1203
|
+
:arg _field: The field to use in this query.
|
|
1204
|
+
:arg _value: The query value for the field.
|
|
1205
|
+
"""
|
|
1206
|
+
|
|
1207
|
+
name = "match_bool_prefix"
|
|
1208
|
+
|
|
1209
|
+
def __init__(
|
|
1210
|
+
self,
|
|
1211
|
+
_field: Union[str, "InstrumentedField", "DefaultType"] = DEFAULT,
|
|
1212
|
+
_value: Union[
|
|
1213
|
+
"types.MatchBoolPrefixQuery", Dict[str, Any], "DefaultType"
|
|
1214
|
+
] = DEFAULT,
|
|
1215
|
+
**kwargs: Any,
|
|
1216
|
+
):
|
|
1217
|
+
if _field is not DEFAULT:
|
|
1218
|
+
kwargs[str(_field)] = _value
|
|
1219
|
+
super().__init__(**kwargs)
|
|
1220
|
+
|
|
1221
|
+
|
|
1222
|
+
class MatchNone(Query):
|
|
1223
|
+
"""
|
|
1224
|
+
Matches no documents.
|
|
1225
|
+
|
|
1226
|
+
:arg boost: Floating point number used to decrease or increase the
|
|
1227
|
+
relevance scores of the query. Boost values are relative to the
|
|
1228
|
+
default value of 1.0. A boost value between 0 and 1.0 decreases
|
|
1229
|
+
the relevance score. A value greater than 1.0 increases the
|
|
1230
|
+
relevance score. Defaults to `1` if omitted.
|
|
1231
|
+
:arg _name:
|
|
1232
|
+
"""
|
|
1233
|
+
|
|
1234
|
+
name = "match_none"
|
|
1235
|
+
|
|
1236
|
+
def __init__(
|
|
1237
|
+
self,
|
|
1238
|
+
*,
|
|
1239
|
+
boost: Union[float, "DefaultType"] = DEFAULT,
|
|
1240
|
+
_name: Union[str, "DefaultType"] = DEFAULT,
|
|
1241
|
+
**kwargs: Any,
|
|
1242
|
+
):
|
|
1243
|
+
super().__init__(boost=boost, _name=_name, **kwargs)
|
|
1244
|
+
|
|
1245
|
+
def __add__(self, other: "Query") -> "MatchNone":
|
|
1246
|
+
return self
|
|
1247
|
+
|
|
1248
|
+
__and__ = __rand__ = __radd__ = __add__
|
|
1249
|
+
|
|
1250
|
+
def __or__(self, other: "Query") -> "Query":
|
|
1251
|
+
return other._clone()
|
|
1252
|
+
|
|
1253
|
+
__ror__ = __or__
|
|
1254
|
+
|
|
1255
|
+
def __invert__(self) -> MatchAll:
|
|
1256
|
+
return MatchAll()
|
|
1257
|
+
|
|
1258
|
+
|
|
1259
|
+
class MatchPhrase(Query):
|
|
1260
|
+
"""
|
|
1261
|
+
Analyzes the text and creates a phrase query out of the analyzed text.
|
|
1262
|
+
|
|
1263
|
+
:arg _field: The field to use in this query.
|
|
1264
|
+
:arg _value: The query value for the field.
|
|
1265
|
+
"""
|
|
1266
|
+
|
|
1267
|
+
name = "match_phrase"
|
|
1268
|
+
|
|
1269
|
+
def __init__(
|
|
1270
|
+
self,
|
|
1271
|
+
_field: Union[str, "InstrumentedField", "DefaultType"] = DEFAULT,
|
|
1272
|
+
_value: Union[
|
|
1273
|
+
"types.MatchPhraseQuery", Dict[str, Any], "DefaultType"
|
|
1274
|
+
] = DEFAULT,
|
|
1275
|
+
**kwargs: Any,
|
|
1276
|
+
):
|
|
1277
|
+
if _field is not DEFAULT:
|
|
1278
|
+
kwargs[str(_field)] = _value
|
|
1279
|
+
super().__init__(**kwargs)
|
|
1280
|
+
|
|
1281
|
+
|
|
1282
|
+
class MatchPhrasePrefix(Query):
|
|
1283
|
+
"""
|
|
1284
|
+
Returns documents that contain the words of a provided text, in the
|
|
1285
|
+
same order as provided. The last term of the provided text is treated
|
|
1286
|
+
as a prefix, matching any words that begin with that term.
|
|
1287
|
+
|
|
1288
|
+
:arg _field: The field to use in this query.
|
|
1289
|
+
:arg _value: The query value for the field.
|
|
1290
|
+
"""
|
|
1291
|
+
|
|
1292
|
+
name = "match_phrase_prefix"
|
|
1293
|
+
|
|
1294
|
+
def __init__(
|
|
1295
|
+
self,
|
|
1296
|
+
_field: Union[str, "InstrumentedField", "DefaultType"] = DEFAULT,
|
|
1297
|
+
_value: Union[
|
|
1298
|
+
"types.MatchPhrasePrefixQuery", Dict[str, Any], "DefaultType"
|
|
1299
|
+
] = DEFAULT,
|
|
1300
|
+
**kwargs: Any,
|
|
1301
|
+
):
|
|
1302
|
+
if _field is not DEFAULT:
|
|
1303
|
+
kwargs[str(_field)] = _value
|
|
1304
|
+
super().__init__(**kwargs)
|
|
1305
|
+
|
|
1306
|
+
|
|
1307
|
+
class MoreLikeThis(Query):
|
|
1308
|
+
"""
|
|
1309
|
+
Returns documents that are "like" a given set of documents.
|
|
1310
|
+
|
|
1311
|
+
:arg like: (required) Specifies free form text and/or a single or
|
|
1312
|
+
multiple documents for which you want to find similar documents.
|
|
1313
|
+
:arg analyzer: The analyzer that is used to analyze the free form
|
|
1314
|
+
text. Defaults to the analyzer associated with the first field in
|
|
1315
|
+
fields.
|
|
1316
|
+
:arg boost_terms: Each term in the formed query could be further
|
|
1317
|
+
boosted by their tf-idf score. This sets the boost factor to use
|
|
1318
|
+
when using this feature. Defaults to deactivated (0).
|
|
1319
|
+
:arg fail_on_unsupported_field: Controls whether the query should fail
|
|
1320
|
+
(throw an exception) if any of the specified fields are not of the
|
|
1321
|
+
supported types (`text` or `keyword`). Defaults to `True` if
|
|
1322
|
+
omitted.
|
|
1323
|
+
:arg fields: A list of fields to fetch and analyze the text from.
|
|
1324
|
+
Defaults to the `index.query.default_field` index setting, which
|
|
1325
|
+
has a default value of `*`.
|
|
1326
|
+
:arg include: Specifies whether the input documents should also be
|
|
1327
|
+
included in the search results returned.
|
|
1328
|
+
:arg max_doc_freq: The maximum document frequency above which the
|
|
1329
|
+
terms are ignored from the input document.
|
|
1330
|
+
:arg max_query_terms: The maximum number of query terms that can be
|
|
1331
|
+
selected. Defaults to `25` if omitted.
|
|
1332
|
+
:arg max_word_length: The maximum word length above which the terms
|
|
1333
|
+
are ignored. Defaults to unbounded (`0`).
|
|
1334
|
+
:arg min_doc_freq: The minimum document frequency below which the
|
|
1335
|
+
terms are ignored from the input document. Defaults to `5` if
|
|
1336
|
+
omitted.
|
|
1337
|
+
:arg minimum_should_match: After the disjunctive query has been
|
|
1338
|
+
formed, this parameter controls the number of terms that must
|
|
1339
|
+
match.
|
|
1340
|
+
:arg min_term_freq: The minimum term frequency below which the terms
|
|
1341
|
+
are ignored from the input document. Defaults to `2` if omitted.
|
|
1342
|
+
:arg min_word_length: The minimum word length below which the terms
|
|
1343
|
+
are ignored.
|
|
1344
|
+
:arg routing:
|
|
1345
|
+
:arg stop_words: An array of stop words. Any word in this set is
|
|
1346
|
+
ignored.
|
|
1347
|
+
:arg unlike: Used in combination with `like` to exclude documents that
|
|
1348
|
+
match a set of terms.
|
|
1349
|
+
:arg version:
|
|
1350
|
+
:arg version_type: Defaults to `'internal'` if omitted.
|
|
1351
|
+
:arg boost: Floating point number used to decrease or increase the
|
|
1352
|
+
relevance scores of the query. Boost values are relative to the
|
|
1353
|
+
default value of 1.0. A boost value between 0 and 1.0 decreases
|
|
1354
|
+
the relevance score. A value greater than 1.0 increases the
|
|
1355
|
+
relevance score. Defaults to `1` if omitted.
|
|
1356
|
+
:arg _name:
|
|
1357
|
+
"""
|
|
1358
|
+
|
|
1359
|
+
name = "more_like_this"
|
|
1360
|
+
|
|
1361
|
+
def __init__(
|
|
1362
|
+
self,
|
|
1363
|
+
*,
|
|
1364
|
+
like: Union[
|
|
1365
|
+
Union[str, "types.LikeDocument"],
|
|
1366
|
+
Sequence[Union[str, "types.LikeDocument"]],
|
|
1367
|
+
Dict[str, Any],
|
|
1368
|
+
"DefaultType",
|
|
1369
|
+
] = DEFAULT,
|
|
1370
|
+
analyzer: Union[str, "DefaultType"] = DEFAULT,
|
|
1371
|
+
boost_terms: Union[float, "DefaultType"] = DEFAULT,
|
|
1372
|
+
fail_on_unsupported_field: Union[bool, "DefaultType"] = DEFAULT,
|
|
1373
|
+
fields: Union[
|
|
1374
|
+
Sequence[Union[str, "InstrumentedField"]], "DefaultType"
|
|
1375
|
+
] = DEFAULT,
|
|
1376
|
+
include: Union[bool, "DefaultType"] = DEFAULT,
|
|
1377
|
+
max_doc_freq: Union[int, "DefaultType"] = DEFAULT,
|
|
1378
|
+
max_query_terms: Union[int, "DefaultType"] = DEFAULT,
|
|
1379
|
+
max_word_length: Union[int, "DefaultType"] = DEFAULT,
|
|
1380
|
+
min_doc_freq: Union[int, "DefaultType"] = DEFAULT,
|
|
1381
|
+
minimum_should_match: Union[int, str, "DefaultType"] = DEFAULT,
|
|
1382
|
+
min_term_freq: Union[int, "DefaultType"] = DEFAULT,
|
|
1383
|
+
min_word_length: Union[int, "DefaultType"] = DEFAULT,
|
|
1384
|
+
routing: Union[str, "DefaultType"] = DEFAULT,
|
|
1385
|
+
stop_words: Union[str, Sequence[str], "DefaultType"] = DEFAULT,
|
|
1386
|
+
unlike: Union[
|
|
1387
|
+
Union[str, "types.LikeDocument"],
|
|
1388
|
+
Sequence[Union[str, "types.LikeDocument"]],
|
|
1389
|
+
Dict[str, Any],
|
|
1390
|
+
"DefaultType",
|
|
1391
|
+
] = DEFAULT,
|
|
1392
|
+
version: Union[int, "DefaultType"] = DEFAULT,
|
|
1393
|
+
version_type: Union[
|
|
1394
|
+
Literal["internal", "external", "external_gte", "force"], "DefaultType"
|
|
1395
|
+
] = DEFAULT,
|
|
1396
|
+
boost: Union[float, "DefaultType"] = DEFAULT,
|
|
1397
|
+
_name: Union[str, "DefaultType"] = DEFAULT,
|
|
1398
|
+
**kwargs: Any,
|
|
1399
|
+
):
|
|
1400
|
+
super().__init__(
|
|
1401
|
+
like=like,
|
|
1402
|
+
analyzer=analyzer,
|
|
1403
|
+
boost_terms=boost_terms,
|
|
1404
|
+
fail_on_unsupported_field=fail_on_unsupported_field,
|
|
1405
|
+
fields=fields,
|
|
1406
|
+
include=include,
|
|
1407
|
+
max_doc_freq=max_doc_freq,
|
|
1408
|
+
max_query_terms=max_query_terms,
|
|
1409
|
+
max_word_length=max_word_length,
|
|
1410
|
+
min_doc_freq=min_doc_freq,
|
|
1411
|
+
minimum_should_match=minimum_should_match,
|
|
1412
|
+
min_term_freq=min_term_freq,
|
|
1413
|
+
min_word_length=min_word_length,
|
|
1414
|
+
routing=routing,
|
|
1415
|
+
stop_words=stop_words,
|
|
1416
|
+
unlike=unlike,
|
|
1417
|
+
version=version,
|
|
1418
|
+
version_type=version_type,
|
|
1419
|
+
boost=boost,
|
|
1420
|
+
_name=_name,
|
|
1421
|
+
**kwargs,
|
|
1422
|
+
)
|
|
1423
|
+
|
|
1424
|
+
|
|
1425
|
+
class MultiMatch(Query):
|
|
1426
|
+
"""
|
|
1427
|
+
Enables you to search for a provided text, number, date or boolean
|
|
1428
|
+
value across multiple fields. The provided text is analyzed before
|
|
1429
|
+
matching.
|
|
1430
|
+
|
|
1431
|
+
:arg query: (required) Text, number, boolean value or date you wish to
|
|
1432
|
+
find in the provided field.
|
|
1433
|
+
:arg analyzer: Analyzer used to convert the text in the query value
|
|
1434
|
+
into tokens.
|
|
1435
|
+
:arg auto_generate_synonyms_phrase_query: If `true`, match phrase
|
|
1436
|
+
queries are automatically created for multi-term synonyms.
|
|
1437
|
+
Defaults to `True` if omitted.
|
|
1438
|
+
:arg cutoff_frequency:
|
|
1439
|
+
:arg fields: The fields to be queried. Defaults to the
|
|
1440
|
+
`index.query.default_field` index settings, which in turn defaults
|
|
1441
|
+
to `*`.
|
|
1442
|
+
:arg fuzziness: Maximum edit distance allowed for matching.
|
|
1443
|
+
:arg fuzzy_rewrite: Method used to rewrite the query.
|
|
1444
|
+
:arg fuzzy_transpositions: If `true`, edits for fuzzy matching include
|
|
1445
|
+
transpositions of two adjacent characters (for example, `ab` to
|
|
1446
|
+
`ba`). Can be applied to the term subqueries constructed for all
|
|
1447
|
+
terms but the final term. Defaults to `True` if omitted.
|
|
1448
|
+
:arg lenient: If `true`, format-based errors, such as providing a text
|
|
1449
|
+
query value for a numeric field, are ignored.
|
|
1450
|
+
:arg max_expansions: Maximum number of terms to which the query will
|
|
1451
|
+
expand. Defaults to `50` if omitted.
|
|
1452
|
+
:arg minimum_should_match: Minimum number of clauses that must match
|
|
1453
|
+
for a document to be returned.
|
|
1454
|
+
:arg operator: Boolean logic used to interpret text in the query
|
|
1455
|
+
value. Defaults to `'or'` if omitted.
|
|
1456
|
+
:arg prefix_length: Number of beginning characters left unchanged for
|
|
1457
|
+
fuzzy matching.
|
|
1458
|
+
:arg slop: Maximum number of positions allowed between matching
|
|
1459
|
+
tokens.
|
|
1460
|
+
:arg tie_breaker: Determines how scores for each per-term blended
|
|
1461
|
+
query and scores across groups are combined.
|
|
1462
|
+
:arg type: How `the` multi_match query is executed internally.
|
|
1463
|
+
Defaults to `'best_fields'` if omitted.
|
|
1464
|
+
:arg zero_terms_query: Indicates whether no documents are returned if
|
|
1465
|
+
the `analyzer` removes all tokens, such as when using a `stop`
|
|
1466
|
+
filter. Defaults to `'none'` if omitted.
|
|
1467
|
+
:arg boost: Floating point number used to decrease or increase the
|
|
1468
|
+
relevance scores of the query. Boost values are relative to the
|
|
1469
|
+
default value of 1.0. A boost value between 0 and 1.0 decreases
|
|
1470
|
+
the relevance score. A value greater than 1.0 increases the
|
|
1471
|
+
relevance score. Defaults to `1` if omitted.
|
|
1472
|
+
:arg _name:
|
|
1473
|
+
"""
|
|
1474
|
+
|
|
1475
|
+
name = "multi_match"
|
|
1476
|
+
|
|
1477
|
+
def __init__(
|
|
1478
|
+
self,
|
|
1479
|
+
*,
|
|
1480
|
+
query: Union[str, "DefaultType"] = DEFAULT,
|
|
1481
|
+
analyzer: Union[str, "DefaultType"] = DEFAULT,
|
|
1482
|
+
auto_generate_synonyms_phrase_query: Union[bool, "DefaultType"] = DEFAULT,
|
|
1483
|
+
cutoff_frequency: Union[float, "DefaultType"] = DEFAULT,
|
|
1484
|
+
fields: Union[
|
|
1485
|
+
Union[str, "InstrumentedField"],
|
|
1486
|
+
Sequence[Union[str, "InstrumentedField"]],
|
|
1487
|
+
"DefaultType",
|
|
1488
|
+
] = DEFAULT,
|
|
1489
|
+
fuzziness: Union[str, int, "DefaultType"] = DEFAULT,
|
|
1490
|
+
fuzzy_rewrite: Union[str, "DefaultType"] = DEFAULT,
|
|
1491
|
+
fuzzy_transpositions: Union[bool, "DefaultType"] = DEFAULT,
|
|
1492
|
+
lenient: Union[bool, "DefaultType"] = DEFAULT,
|
|
1493
|
+
max_expansions: Union[int, "DefaultType"] = DEFAULT,
|
|
1494
|
+
minimum_should_match: Union[int, str, "DefaultType"] = DEFAULT,
|
|
1495
|
+
operator: Union[Literal["and", "or"], "DefaultType"] = DEFAULT,
|
|
1496
|
+
prefix_length: Union[int, "DefaultType"] = DEFAULT,
|
|
1497
|
+
slop: Union[int, "DefaultType"] = DEFAULT,
|
|
1498
|
+
tie_breaker: Union[float, "DefaultType"] = DEFAULT,
|
|
1499
|
+
type: Union[
|
|
1500
|
+
Literal[
|
|
1501
|
+
"best_fields",
|
|
1502
|
+
"most_fields",
|
|
1503
|
+
"cross_fields",
|
|
1504
|
+
"phrase",
|
|
1505
|
+
"phrase_prefix",
|
|
1506
|
+
"bool_prefix",
|
|
1507
|
+
],
|
|
1508
|
+
"DefaultType",
|
|
1509
|
+
] = DEFAULT,
|
|
1510
|
+
zero_terms_query: Union[Literal["all", "none"], "DefaultType"] = DEFAULT,
|
|
1511
|
+
boost: Union[float, "DefaultType"] = DEFAULT,
|
|
1512
|
+
_name: Union[str, "DefaultType"] = DEFAULT,
|
|
1513
|
+
**kwargs: Any,
|
|
1514
|
+
):
|
|
1515
|
+
super().__init__(
|
|
1516
|
+
query=query,
|
|
1517
|
+
analyzer=analyzer,
|
|
1518
|
+
auto_generate_synonyms_phrase_query=auto_generate_synonyms_phrase_query,
|
|
1519
|
+
cutoff_frequency=cutoff_frequency,
|
|
1520
|
+
fields=fields,
|
|
1521
|
+
fuzziness=fuzziness,
|
|
1522
|
+
fuzzy_rewrite=fuzzy_rewrite,
|
|
1523
|
+
fuzzy_transpositions=fuzzy_transpositions,
|
|
1524
|
+
lenient=lenient,
|
|
1525
|
+
max_expansions=max_expansions,
|
|
1526
|
+
minimum_should_match=minimum_should_match,
|
|
1527
|
+
operator=operator,
|
|
1528
|
+
prefix_length=prefix_length,
|
|
1529
|
+
slop=slop,
|
|
1530
|
+
tie_breaker=tie_breaker,
|
|
1531
|
+
type=type,
|
|
1532
|
+
zero_terms_query=zero_terms_query,
|
|
1533
|
+
boost=boost,
|
|
1534
|
+
_name=_name,
|
|
1535
|
+
**kwargs,
|
|
1536
|
+
)
|
|
1537
|
+
|
|
1538
|
+
|
|
1539
|
+
class Nested(Query):
|
|
1540
|
+
"""
|
|
1541
|
+
Wraps another query to search nested fields. If an object matches the
|
|
1542
|
+
search, the nested query returns the root parent document.
|
|
1543
|
+
|
|
1544
|
+
:arg path: (required) Path to the nested object you wish to search.
|
|
1545
|
+
:arg query: (required) Query you wish to run on nested objects in the
|
|
1546
|
+
path.
|
|
1547
|
+
:arg ignore_unmapped: Indicates whether to ignore an unmapped path and
|
|
1548
|
+
not return any documents instead of an error.
|
|
1549
|
+
:arg inner_hits: If defined, each search hit will contain inner hits.
|
|
1550
|
+
:arg score_mode: How scores for matching child objects affect the root
|
|
1551
|
+
parent document’s relevance score. Defaults to `'avg'` if omitted.
|
|
1552
|
+
:arg boost: Floating point number used to decrease or increase the
|
|
1553
|
+
relevance scores of the query. Boost values are relative to the
|
|
1554
|
+
default value of 1.0. A boost value between 0 and 1.0 decreases
|
|
1555
|
+
the relevance score. A value greater than 1.0 increases the
|
|
1556
|
+
relevance score. Defaults to `1` if omitted.
|
|
1557
|
+
:arg _name:
|
|
1558
|
+
"""
|
|
1559
|
+
|
|
1560
|
+
name = "nested"
|
|
1561
|
+
_param_defs = {
|
|
1562
|
+
"query": {"type": "query"},
|
|
1563
|
+
}
|
|
1564
|
+
|
|
1565
|
+
def __init__(
|
|
1566
|
+
self,
|
|
1567
|
+
*,
|
|
1568
|
+
path: Union[str, "InstrumentedField", "DefaultType"] = DEFAULT,
|
|
1569
|
+
query: Union[Query, "DefaultType"] = DEFAULT,
|
|
1570
|
+
ignore_unmapped: Union[bool, "DefaultType"] = DEFAULT,
|
|
1571
|
+
inner_hits: Union["types.InnerHits", Dict[str, Any], "DefaultType"] = DEFAULT,
|
|
1572
|
+
score_mode: Union[
|
|
1573
|
+
Literal["none", "avg", "sum", "max", "min"], "DefaultType"
|
|
1574
|
+
] = DEFAULT,
|
|
1575
|
+
boost: Union[float, "DefaultType"] = DEFAULT,
|
|
1576
|
+
_name: Union[str, "DefaultType"] = DEFAULT,
|
|
1577
|
+
**kwargs: Any,
|
|
1578
|
+
):
|
|
1579
|
+
super().__init__(
|
|
1580
|
+
path=path,
|
|
1581
|
+
query=query,
|
|
1582
|
+
ignore_unmapped=ignore_unmapped,
|
|
1583
|
+
inner_hits=inner_hits,
|
|
1584
|
+
score_mode=score_mode,
|
|
1585
|
+
boost=boost,
|
|
1586
|
+
_name=_name,
|
|
1587
|
+
**kwargs,
|
|
1588
|
+
)
|
|
1589
|
+
|
|
1590
|
+
|
|
1591
|
+
class ParentId(Query):
|
|
1592
|
+
"""
|
|
1593
|
+
Returns child documents joined to a specific parent document.
|
|
1594
|
+
|
|
1595
|
+
:arg id: ID of the parent document.
|
|
1596
|
+
:arg ignore_unmapped: Indicates whether to ignore an unmapped `type`
|
|
1597
|
+
and not return any documents instead of an error.
|
|
1598
|
+
:arg type: Name of the child relationship mapped for the `join` field.
|
|
1599
|
+
:arg boost: Floating point number used to decrease or increase the
|
|
1600
|
+
relevance scores of the query. Boost values are relative to the
|
|
1601
|
+
default value of 1.0. A boost value between 0 and 1.0 decreases
|
|
1602
|
+
the relevance score. A value greater than 1.0 increases the
|
|
1603
|
+
relevance score. Defaults to `1` if omitted.
|
|
1604
|
+
:arg _name:
|
|
1605
|
+
"""
|
|
1606
|
+
|
|
1607
|
+
name = "parent_id"
|
|
1608
|
+
|
|
1609
|
+
def __init__(
|
|
1610
|
+
self,
|
|
1611
|
+
*,
|
|
1612
|
+
id: Union[str, "DefaultType"] = DEFAULT,
|
|
1613
|
+
ignore_unmapped: Union[bool, "DefaultType"] = DEFAULT,
|
|
1614
|
+
type: Union[str, "DefaultType"] = DEFAULT,
|
|
1615
|
+
boost: Union[float, "DefaultType"] = DEFAULT,
|
|
1616
|
+
_name: Union[str, "DefaultType"] = DEFAULT,
|
|
1617
|
+
**kwargs: Any,
|
|
1618
|
+
):
|
|
1619
|
+
super().__init__(
|
|
1620
|
+
id=id,
|
|
1621
|
+
ignore_unmapped=ignore_unmapped,
|
|
1622
|
+
type=type,
|
|
1623
|
+
boost=boost,
|
|
1624
|
+
_name=_name,
|
|
1625
|
+
**kwargs,
|
|
1626
|
+
)
|
|
1627
|
+
|
|
1628
|
+
|
|
1629
|
+
class Percolate(Query):
|
|
1630
|
+
"""
|
|
1631
|
+
Matches queries stored in an index.
|
|
1632
|
+
|
|
1633
|
+
:arg field: (required) Field that holds the indexed queries. The field
|
|
1634
|
+
must use the `percolator` mapping type.
|
|
1635
|
+
:arg document: The source of the document being percolated.
|
|
1636
|
+
:arg documents: An array of sources of the documents being percolated.
|
|
1637
|
+
:arg id: The ID of a stored document to percolate.
|
|
1638
|
+
:arg index: The index of a stored document to percolate.
|
|
1639
|
+
:arg name: The suffix used for the `_percolator_document_slot` field
|
|
1640
|
+
when multiple `percolate` queries are specified.
|
|
1641
|
+
:arg preference: Preference used to fetch document to percolate.
|
|
1642
|
+
:arg routing: Routing used to fetch document to percolate.
|
|
1643
|
+
:arg version: The expected version of a stored document to percolate.
|
|
1644
|
+
:arg boost: Floating point number used to decrease or increase the
|
|
1645
|
+
relevance scores of the query. Boost values are relative to the
|
|
1646
|
+
default value of 1.0. A boost value between 0 and 1.0 decreases
|
|
1647
|
+
the relevance score. A value greater than 1.0 increases the
|
|
1648
|
+
relevance score. Defaults to `1` if omitted.
|
|
1649
|
+
:arg _name:
|
|
1650
|
+
"""
|
|
1651
|
+
|
|
1652
|
+
name = "percolate"
|
|
1653
|
+
|
|
1654
|
+
def __init__(
|
|
1655
|
+
self,
|
|
1656
|
+
*,
|
|
1657
|
+
field: Union[str, "InstrumentedField", "DefaultType"] = DEFAULT,
|
|
1658
|
+
document: Any = DEFAULT,
|
|
1659
|
+
documents: Union[Sequence[Any], "DefaultType"] = DEFAULT,
|
|
1660
|
+
id: Union[str, "DefaultType"] = DEFAULT,
|
|
1661
|
+
index: Union[str, "DefaultType"] = DEFAULT,
|
|
1662
|
+
name: Union[str, "DefaultType"] = DEFAULT,
|
|
1663
|
+
preference: Union[str, "DefaultType"] = DEFAULT,
|
|
1664
|
+
routing: Union[str, "DefaultType"] = DEFAULT,
|
|
1665
|
+
version: Union[int, "DefaultType"] = DEFAULT,
|
|
1666
|
+
boost: Union[float, "DefaultType"] = DEFAULT,
|
|
1667
|
+
_name: Union[str, "DefaultType"] = DEFAULT,
|
|
1668
|
+
**kwargs: Any,
|
|
1669
|
+
):
|
|
1670
|
+
super().__init__(
|
|
1671
|
+
field=field,
|
|
1672
|
+
document=document,
|
|
1673
|
+
documents=documents,
|
|
1674
|
+
id=id,
|
|
1675
|
+
index=index,
|
|
1676
|
+
name=name,
|
|
1677
|
+
preference=preference,
|
|
1678
|
+
routing=routing,
|
|
1679
|
+
version=version,
|
|
1680
|
+
boost=boost,
|
|
1681
|
+
_name=_name,
|
|
1682
|
+
**kwargs,
|
|
1683
|
+
)
|
|
1684
|
+
|
|
1685
|
+
|
|
1686
|
+
class Pinned(Query):
|
|
1687
|
+
"""
|
|
1688
|
+
Promotes selected documents to rank higher than those matching a given
|
|
1689
|
+
query.
|
|
1690
|
+
|
|
1691
|
+
:arg organic: (required) Any choice of query used to rank documents
|
|
1692
|
+
which will be ranked below the "pinned" documents.
|
|
1693
|
+
:arg ids: Document IDs listed in the order they are to appear in
|
|
1694
|
+
results. Required if `docs` is not specified.
|
|
1695
|
+
:arg docs: Documents listed in the order they are to appear in
|
|
1696
|
+
results. Required if `ids` is not specified.
|
|
1697
|
+
:arg boost: Floating point number used to decrease or increase the
|
|
1698
|
+
relevance scores of the query. Boost values are relative to the
|
|
1699
|
+
default value of 1.0. A boost value between 0 and 1.0 decreases
|
|
1700
|
+
the relevance score. A value greater than 1.0 increases the
|
|
1701
|
+
relevance score. Defaults to `1` if omitted.
|
|
1702
|
+
:arg _name:
|
|
1703
|
+
"""
|
|
1704
|
+
|
|
1705
|
+
name = "pinned"
|
|
1706
|
+
_param_defs = {
|
|
1707
|
+
"organic": {"type": "query"},
|
|
1708
|
+
}
|
|
1709
|
+
|
|
1710
|
+
def __init__(
|
|
1711
|
+
self,
|
|
1712
|
+
*,
|
|
1713
|
+
organic: Union[Query, "DefaultType"] = DEFAULT,
|
|
1714
|
+
ids: Union[Sequence[str], "DefaultType"] = DEFAULT,
|
|
1715
|
+
docs: Union[
|
|
1716
|
+
Sequence["types.PinnedDoc"], Sequence[Dict[str, Any]], "DefaultType"
|
|
1717
|
+
] = DEFAULT,
|
|
1718
|
+
boost: Union[float, "DefaultType"] = DEFAULT,
|
|
1719
|
+
_name: Union[str, "DefaultType"] = DEFAULT,
|
|
1720
|
+
**kwargs: Any,
|
|
1721
|
+
):
|
|
1722
|
+
super().__init__(
|
|
1723
|
+
organic=organic, ids=ids, docs=docs, boost=boost, _name=_name, **kwargs
|
|
1724
|
+
)
|
|
1725
|
+
|
|
1726
|
+
|
|
1727
|
+
class Prefix(Query):
|
|
1728
|
+
"""
|
|
1729
|
+
Returns documents that contain a specific prefix in a provided field.
|
|
1730
|
+
|
|
1731
|
+
:arg _field: The field to use in this query.
|
|
1732
|
+
:arg _value: The query value for the field.
|
|
1733
|
+
"""
|
|
1734
|
+
|
|
1735
|
+
name = "prefix"
|
|
1736
|
+
|
|
1737
|
+
def __init__(
|
|
1738
|
+
self,
|
|
1739
|
+
_field: Union[str, "InstrumentedField", "DefaultType"] = DEFAULT,
|
|
1740
|
+
_value: Union["types.PrefixQuery", Dict[str, Any], "DefaultType"] = DEFAULT,
|
|
1741
|
+
**kwargs: Any,
|
|
1742
|
+
):
|
|
1743
|
+
if _field is not DEFAULT:
|
|
1744
|
+
kwargs[str(_field)] = _value
|
|
1745
|
+
super().__init__(**kwargs)
|
|
1746
|
+
|
|
1747
|
+
|
|
1748
|
+
class QueryString(Query):
|
|
1749
|
+
"""
|
|
1750
|
+
Returns documents based on a provided query string, using a parser
|
|
1751
|
+
with a strict syntax.
|
|
1752
|
+
|
|
1753
|
+
:arg query: (required) Query string you wish to parse and use for
|
|
1754
|
+
search.
|
|
1755
|
+
:arg allow_leading_wildcard: If `true`, the wildcard characters `*`
|
|
1756
|
+
and `?` are allowed as the first character of the query string.
|
|
1757
|
+
Defaults to `True` if omitted.
|
|
1758
|
+
:arg analyzer: Analyzer used to convert text in the query string into
|
|
1759
|
+
tokens.
|
|
1760
|
+
:arg analyze_wildcard: If `true`, the query attempts to analyze
|
|
1761
|
+
wildcard terms in the query string.
|
|
1762
|
+
:arg auto_generate_synonyms_phrase_query: If `true`, match phrase
|
|
1763
|
+
queries are automatically created for multi-term synonyms.
|
|
1764
|
+
Defaults to `True` if omitted.
|
|
1765
|
+
:arg default_field: Default field to search if no field is provided in
|
|
1766
|
+
the query string. Supports wildcards (`*`). Defaults to the
|
|
1767
|
+
`index.query.default_field` index setting, which has a default
|
|
1768
|
+
value of `*`.
|
|
1769
|
+
:arg default_operator: Default boolean logic used to interpret text in
|
|
1770
|
+
the query string if no operators are specified. Defaults to `'or'`
|
|
1771
|
+
if omitted.
|
|
1772
|
+
:arg enable_position_increments: If `true`, enable position increments
|
|
1773
|
+
in queries constructed from a `query_string` search. Defaults to
|
|
1774
|
+
`True` if omitted.
|
|
1775
|
+
:arg escape:
|
|
1776
|
+
:arg fields: Array of fields to search. Supports wildcards (`*`).
|
|
1777
|
+
:arg fuzziness: Maximum edit distance allowed for fuzzy matching.
|
|
1778
|
+
:arg fuzzy_max_expansions: Maximum number of terms to which the query
|
|
1779
|
+
expands for fuzzy matching. Defaults to `50` if omitted.
|
|
1780
|
+
:arg fuzzy_prefix_length: Number of beginning characters left
|
|
1781
|
+
unchanged for fuzzy matching.
|
|
1782
|
+
:arg fuzzy_rewrite: Method used to rewrite the query.
|
|
1783
|
+
:arg fuzzy_transpositions: If `true`, edits for fuzzy matching include
|
|
1784
|
+
transpositions of two adjacent characters (for example, `ab` to
|
|
1785
|
+
`ba`). Defaults to `True` if omitted.
|
|
1786
|
+
:arg lenient: If `true`, format-based errors, such as providing a text
|
|
1787
|
+
value for a numeric field, are ignored.
|
|
1788
|
+
:arg max_determinized_states: Maximum number of automaton states
|
|
1789
|
+
required for the query. Defaults to `10000` if omitted.
|
|
1790
|
+
:arg minimum_should_match: Minimum number of clauses that must match
|
|
1791
|
+
for a document to be returned.
|
|
1792
|
+
:arg phrase_slop: Maximum number of positions allowed between matching
|
|
1793
|
+
tokens for phrases.
|
|
1794
|
+
:arg quote_analyzer: Analyzer used to convert quoted text in the query
|
|
1795
|
+
string into tokens. For quoted text, this parameter overrides the
|
|
1796
|
+
analyzer specified in the `analyzer` parameter.
|
|
1797
|
+
:arg quote_field_suffix: Suffix appended to quoted text in the query
|
|
1798
|
+
string. You can use this suffix to use a different analysis method
|
|
1799
|
+
for exact matches.
|
|
1800
|
+
:arg rewrite: Method used to rewrite the query.
|
|
1801
|
+
:arg tie_breaker: How to combine the queries generated from the
|
|
1802
|
+
individual search terms in the resulting `dis_max` query.
|
|
1803
|
+
:arg time_zone: Coordinated Universal Time (UTC) offset or IANA time
|
|
1804
|
+
zone used to convert date values in the query string to UTC.
|
|
1805
|
+
:arg type: Determines how the query matches and scores documents.
|
|
1806
|
+
Defaults to `'best_fields'` if omitted.
|
|
1807
|
+
:arg boost: Floating point number used to decrease or increase the
|
|
1808
|
+
relevance scores of the query. Boost values are relative to the
|
|
1809
|
+
default value of 1.0. A boost value between 0 and 1.0 decreases
|
|
1810
|
+
the relevance score. A value greater than 1.0 increases the
|
|
1811
|
+
relevance score. Defaults to `1` if omitted.
|
|
1812
|
+
:arg _name:
|
|
1813
|
+
"""
|
|
1814
|
+
|
|
1815
|
+
name = "query_string"
|
|
1816
|
+
|
|
1817
|
+
def __init__(
|
|
1818
|
+
self,
|
|
1819
|
+
*,
|
|
1820
|
+
query: Union[str, "DefaultType"] = DEFAULT,
|
|
1821
|
+
allow_leading_wildcard: Union[bool, "DefaultType"] = DEFAULT,
|
|
1822
|
+
analyzer: Union[str, "DefaultType"] = DEFAULT,
|
|
1823
|
+
analyze_wildcard: Union[bool, "DefaultType"] = DEFAULT,
|
|
1824
|
+
auto_generate_synonyms_phrase_query: Union[bool, "DefaultType"] = DEFAULT,
|
|
1825
|
+
default_field: Union[str, "InstrumentedField", "DefaultType"] = DEFAULT,
|
|
1826
|
+
default_operator: Union[Literal["and", "or"], "DefaultType"] = DEFAULT,
|
|
1827
|
+
enable_position_increments: Union[bool, "DefaultType"] = DEFAULT,
|
|
1828
|
+
escape: Union[bool, "DefaultType"] = DEFAULT,
|
|
1829
|
+
fields: Union[
|
|
1830
|
+
Sequence[Union[str, "InstrumentedField"]], "DefaultType"
|
|
1831
|
+
] = DEFAULT,
|
|
1832
|
+
fuzziness: Union[str, int, "DefaultType"] = DEFAULT,
|
|
1833
|
+
fuzzy_max_expansions: Union[int, "DefaultType"] = DEFAULT,
|
|
1834
|
+
fuzzy_prefix_length: Union[int, "DefaultType"] = DEFAULT,
|
|
1835
|
+
fuzzy_rewrite: Union[str, "DefaultType"] = DEFAULT,
|
|
1836
|
+
fuzzy_transpositions: Union[bool, "DefaultType"] = DEFAULT,
|
|
1837
|
+
lenient: Union[bool, "DefaultType"] = DEFAULT,
|
|
1838
|
+
max_determinized_states: Union[int, "DefaultType"] = DEFAULT,
|
|
1839
|
+
minimum_should_match: Union[int, str, "DefaultType"] = DEFAULT,
|
|
1840
|
+
phrase_slop: Union[float, "DefaultType"] = DEFAULT,
|
|
1841
|
+
quote_analyzer: Union[str, "DefaultType"] = DEFAULT,
|
|
1842
|
+
quote_field_suffix: Union[str, "DefaultType"] = DEFAULT,
|
|
1843
|
+
rewrite: Union[str, "DefaultType"] = DEFAULT,
|
|
1844
|
+
tie_breaker: Union[float, "DefaultType"] = DEFAULT,
|
|
1845
|
+
time_zone: Union[str, "DefaultType"] = DEFAULT,
|
|
1846
|
+
type: Union[
|
|
1847
|
+
Literal[
|
|
1848
|
+
"best_fields",
|
|
1849
|
+
"most_fields",
|
|
1850
|
+
"cross_fields",
|
|
1851
|
+
"phrase",
|
|
1852
|
+
"phrase_prefix",
|
|
1853
|
+
"bool_prefix",
|
|
1854
|
+
],
|
|
1855
|
+
"DefaultType",
|
|
1856
|
+
] = DEFAULT,
|
|
1857
|
+
boost: Union[float, "DefaultType"] = DEFAULT,
|
|
1858
|
+
_name: Union[str, "DefaultType"] = DEFAULT,
|
|
1859
|
+
**kwargs: Any,
|
|
1860
|
+
):
|
|
1861
|
+
super().__init__(
|
|
1862
|
+
query=query,
|
|
1863
|
+
allow_leading_wildcard=allow_leading_wildcard,
|
|
1864
|
+
analyzer=analyzer,
|
|
1865
|
+
analyze_wildcard=analyze_wildcard,
|
|
1866
|
+
auto_generate_synonyms_phrase_query=auto_generate_synonyms_phrase_query,
|
|
1867
|
+
default_field=default_field,
|
|
1868
|
+
default_operator=default_operator,
|
|
1869
|
+
enable_position_increments=enable_position_increments,
|
|
1870
|
+
escape=escape,
|
|
1871
|
+
fields=fields,
|
|
1872
|
+
fuzziness=fuzziness,
|
|
1873
|
+
fuzzy_max_expansions=fuzzy_max_expansions,
|
|
1874
|
+
fuzzy_prefix_length=fuzzy_prefix_length,
|
|
1875
|
+
fuzzy_rewrite=fuzzy_rewrite,
|
|
1876
|
+
fuzzy_transpositions=fuzzy_transpositions,
|
|
1877
|
+
lenient=lenient,
|
|
1878
|
+
max_determinized_states=max_determinized_states,
|
|
1879
|
+
minimum_should_match=minimum_should_match,
|
|
1880
|
+
phrase_slop=phrase_slop,
|
|
1881
|
+
quote_analyzer=quote_analyzer,
|
|
1882
|
+
quote_field_suffix=quote_field_suffix,
|
|
1883
|
+
rewrite=rewrite,
|
|
1884
|
+
tie_breaker=tie_breaker,
|
|
1885
|
+
time_zone=time_zone,
|
|
1886
|
+
type=type,
|
|
1887
|
+
boost=boost,
|
|
1888
|
+
_name=_name,
|
|
1889
|
+
**kwargs,
|
|
1890
|
+
)
|
|
1891
|
+
|
|
1892
|
+
|
|
1893
|
+
class Range(Query):
|
|
1894
|
+
"""
|
|
1895
|
+
Returns documents that contain terms within a provided range.
|
|
1896
|
+
|
|
1897
|
+
:arg _field: The field to use in this query.
|
|
1898
|
+
:arg _value: The query value for the field.
|
|
1899
|
+
"""
|
|
1900
|
+
|
|
1901
|
+
name = "range"
|
|
1902
|
+
|
|
1903
|
+
def __init__(
|
|
1904
|
+
self,
|
|
1905
|
+
_field: Union[str, "InstrumentedField", "DefaultType"] = DEFAULT,
|
|
1906
|
+
_value: Union["wrappers.Range[Any]", Dict[str, Any], "DefaultType"] = DEFAULT,
|
|
1907
|
+
**kwargs: Any,
|
|
1908
|
+
):
|
|
1909
|
+
if _field is not DEFAULT:
|
|
1910
|
+
kwargs[str(_field)] = _value
|
|
1911
|
+
super().__init__(**kwargs)
|
|
1912
|
+
|
|
1913
|
+
|
|
1914
|
+
class RankFeature(Query):
|
|
1915
|
+
"""
|
|
1916
|
+
Boosts the relevance score of documents based on the numeric value of
|
|
1917
|
+
a `rank_feature` or `rank_features` field.
|
|
1918
|
+
|
|
1919
|
+
:arg field: (required) `rank_feature` or `rank_features` field used to
|
|
1920
|
+
boost relevance scores.
|
|
1921
|
+
:arg saturation: Saturation function used to boost relevance scores
|
|
1922
|
+
based on the value of the rank feature `field`.
|
|
1923
|
+
:arg log: Logarithmic function used to boost relevance scores based on
|
|
1924
|
+
the value of the rank feature `field`.
|
|
1925
|
+
:arg linear: Linear function used to boost relevance scores based on
|
|
1926
|
+
the value of the rank feature `field`.
|
|
1927
|
+
:arg sigmoid: Sigmoid function used to boost relevance scores based on
|
|
1928
|
+
the value of the rank feature `field`.
|
|
1929
|
+
:arg boost: Floating point number used to decrease or increase the
|
|
1930
|
+
relevance scores of the query. Boost values are relative to the
|
|
1931
|
+
default value of 1.0. A boost value between 0 and 1.0 decreases
|
|
1932
|
+
the relevance score. A value greater than 1.0 increases the
|
|
1933
|
+
relevance score. Defaults to `1` if omitted.
|
|
1934
|
+
:arg _name:
|
|
1935
|
+
"""
|
|
1936
|
+
|
|
1937
|
+
name = "rank_feature"
|
|
1938
|
+
|
|
1939
|
+
def __init__(
|
|
1940
|
+
self,
|
|
1941
|
+
*,
|
|
1942
|
+
field: Union[str, "InstrumentedField", "DefaultType"] = DEFAULT,
|
|
1943
|
+
saturation: Union[
|
|
1944
|
+
"types.RankFeatureFunctionSaturation", Dict[str, Any], "DefaultType"
|
|
1945
|
+
] = DEFAULT,
|
|
1946
|
+
log: Union[
|
|
1947
|
+
"types.RankFeatureFunctionLogarithm", Dict[str, Any], "DefaultType"
|
|
1948
|
+
] = DEFAULT,
|
|
1949
|
+
linear: Union[
|
|
1950
|
+
"types.RankFeatureFunctionLinear", Dict[str, Any], "DefaultType"
|
|
1951
|
+
] = DEFAULT,
|
|
1952
|
+
sigmoid: Union[
|
|
1953
|
+
"types.RankFeatureFunctionSigmoid", Dict[str, Any], "DefaultType"
|
|
1954
|
+
] = DEFAULT,
|
|
1955
|
+
boost: Union[float, "DefaultType"] = DEFAULT,
|
|
1956
|
+
_name: Union[str, "DefaultType"] = DEFAULT,
|
|
1957
|
+
**kwargs: Any,
|
|
1958
|
+
):
|
|
1959
|
+
super().__init__(
|
|
1960
|
+
field=field,
|
|
1961
|
+
saturation=saturation,
|
|
1962
|
+
log=log,
|
|
1963
|
+
linear=linear,
|
|
1964
|
+
sigmoid=sigmoid,
|
|
1965
|
+
boost=boost,
|
|
1966
|
+
_name=_name,
|
|
1967
|
+
**kwargs,
|
|
1968
|
+
)
|
|
1969
|
+
|
|
1970
|
+
|
|
1971
|
+
class Regexp(Query):
|
|
1972
|
+
"""
|
|
1973
|
+
Returns documents that contain terms matching a regular expression.
|
|
1974
|
+
|
|
1975
|
+
:arg _field: The field to use in this query.
|
|
1976
|
+
:arg _value: The query value for the field.
|
|
1977
|
+
"""
|
|
1978
|
+
|
|
1979
|
+
name = "regexp"
|
|
1980
|
+
|
|
1981
|
+
def __init__(
|
|
1982
|
+
self,
|
|
1983
|
+
_field: Union[str, "InstrumentedField", "DefaultType"] = DEFAULT,
|
|
1984
|
+
_value: Union["types.RegexpQuery", Dict[str, Any], "DefaultType"] = DEFAULT,
|
|
1985
|
+
**kwargs: Any,
|
|
1986
|
+
):
|
|
1987
|
+
if _field is not DEFAULT:
|
|
1988
|
+
kwargs[str(_field)] = _value
|
|
1989
|
+
super().__init__(**kwargs)
|
|
1990
|
+
|
|
1991
|
+
|
|
1992
|
+
class Rule(Query):
|
|
1993
|
+
"""
|
|
1994
|
+
:arg organic: (required)
|
|
1995
|
+
:arg ruleset_ids: (required)
|
|
1996
|
+
:arg match_criteria: (required)
|
|
1997
|
+
:arg boost: Floating point number used to decrease or increase the
|
|
1998
|
+
relevance scores of the query. Boost values are relative to the
|
|
1999
|
+
default value of 1.0. A boost value between 0 and 1.0 decreases
|
|
2000
|
+
the relevance score. A value greater than 1.0 increases the
|
|
2001
|
+
relevance score. Defaults to `1` if omitted.
|
|
2002
|
+
:arg _name:
|
|
2003
|
+
"""
|
|
2004
|
+
|
|
2005
|
+
name = "rule"
|
|
2006
|
+
_param_defs = {
|
|
2007
|
+
"organic": {"type": "query"},
|
|
2008
|
+
}
|
|
2009
|
+
|
|
2010
|
+
def __init__(
|
|
2011
|
+
self,
|
|
2012
|
+
*,
|
|
2013
|
+
organic: Union[Query, "DefaultType"] = DEFAULT,
|
|
2014
|
+
ruleset_ids: Union[Sequence[str], "DefaultType"] = DEFAULT,
|
|
2015
|
+
match_criteria: Any = DEFAULT,
|
|
2016
|
+
boost: Union[float, "DefaultType"] = DEFAULT,
|
|
2017
|
+
_name: Union[str, "DefaultType"] = DEFAULT,
|
|
2018
|
+
**kwargs: Any,
|
|
2019
|
+
):
|
|
2020
|
+
super().__init__(
|
|
2021
|
+
organic=organic,
|
|
2022
|
+
ruleset_ids=ruleset_ids,
|
|
2023
|
+
match_criteria=match_criteria,
|
|
2024
|
+
boost=boost,
|
|
2025
|
+
_name=_name,
|
|
2026
|
+
**kwargs,
|
|
2027
|
+
)
|
|
2028
|
+
|
|
2029
|
+
|
|
2030
|
+
class Script(Query):
|
|
2031
|
+
"""
|
|
2032
|
+
Filters documents based on a provided script. The script query is
|
|
2033
|
+
typically used in a filter context.
|
|
2034
|
+
|
|
2035
|
+
:arg script: (required) Contains a script to run as a query. This
|
|
2036
|
+
script must return a boolean value, `true` or `false`.
|
|
2037
|
+
:arg boost: Floating point number used to decrease or increase the
|
|
2038
|
+
relevance scores of the query. Boost values are relative to the
|
|
2039
|
+
default value of 1.0. A boost value between 0 and 1.0 decreases
|
|
2040
|
+
the relevance score. A value greater than 1.0 increases the
|
|
2041
|
+
relevance score. Defaults to `1` if omitted.
|
|
2042
|
+
:arg _name:
|
|
2043
|
+
"""
|
|
2044
|
+
|
|
2045
|
+
name = "script"
|
|
2046
|
+
|
|
2047
|
+
def __init__(
|
|
2048
|
+
self,
|
|
2049
|
+
*,
|
|
2050
|
+
script: Union["types.Script", Dict[str, Any], "DefaultType"] = DEFAULT,
|
|
2051
|
+
boost: Union[float, "DefaultType"] = DEFAULT,
|
|
2052
|
+
_name: Union[str, "DefaultType"] = DEFAULT,
|
|
2053
|
+
**kwargs: Any,
|
|
2054
|
+
):
|
|
2055
|
+
super().__init__(script=script, boost=boost, _name=_name, **kwargs)
|
|
2056
|
+
|
|
2057
|
+
|
|
2058
|
+
class ScriptScore(Query):
|
|
2059
|
+
"""
|
|
2060
|
+
Uses a script to provide a custom score for returned documents.
|
|
2061
|
+
|
|
2062
|
+
:arg query: (required) Query used to return documents.
|
|
2063
|
+
:arg script: (required) Script used to compute the score of documents
|
|
2064
|
+
returned by the query. Important: final relevance scores from the
|
|
2065
|
+
`script_score` query cannot be negative.
|
|
2066
|
+
:arg min_score: Documents with a score lower than this floating point
|
|
2067
|
+
number are excluded from the search results.
|
|
2068
|
+
:arg boost: Floating point number used to decrease or increase the
|
|
2069
|
+
relevance scores of the query. Boost values are relative to the
|
|
2070
|
+
default value of 1.0. A boost value between 0 and 1.0 decreases
|
|
2071
|
+
the relevance score. A value greater than 1.0 increases the
|
|
2072
|
+
relevance score. Defaults to `1` if omitted.
|
|
2073
|
+
:arg _name:
|
|
2074
|
+
"""
|
|
2075
|
+
|
|
2076
|
+
name = "script_score"
|
|
2077
|
+
_param_defs = {
|
|
2078
|
+
"query": {"type": "query"},
|
|
2079
|
+
}
|
|
2080
|
+
|
|
2081
|
+
def __init__(
|
|
2082
|
+
self,
|
|
2083
|
+
*,
|
|
2084
|
+
query: Union[Query, "DefaultType"] = DEFAULT,
|
|
2085
|
+
script: Union["types.Script", Dict[str, Any], "DefaultType"] = DEFAULT,
|
|
2086
|
+
min_score: Union[float, "DefaultType"] = DEFAULT,
|
|
2087
|
+
boost: Union[float, "DefaultType"] = DEFAULT,
|
|
2088
|
+
_name: Union[str, "DefaultType"] = DEFAULT,
|
|
2089
|
+
**kwargs: Any,
|
|
2090
|
+
):
|
|
2091
|
+
super().__init__(
|
|
2092
|
+
query=query,
|
|
2093
|
+
script=script,
|
|
2094
|
+
min_score=min_score,
|
|
2095
|
+
boost=boost,
|
|
2096
|
+
_name=_name,
|
|
2097
|
+
**kwargs,
|
|
2098
|
+
)
|
|
2099
|
+
|
|
2100
|
+
|
|
2101
|
+
class Semantic(Query):
|
|
2102
|
+
"""
|
|
2103
|
+
A semantic query to semantic_text field types
|
|
2104
|
+
|
|
2105
|
+
:arg field: (required) The field to query, which must be a
|
|
2106
|
+
semantic_text field type
|
|
2107
|
+
:arg query: (required) The query text
|
|
2108
|
+
:arg boost: Floating point number used to decrease or increase the
|
|
2109
|
+
relevance scores of the query. Boost values are relative to the
|
|
2110
|
+
default value of 1.0. A boost value between 0 and 1.0 decreases
|
|
2111
|
+
the relevance score. A value greater than 1.0 increases the
|
|
2112
|
+
relevance score. Defaults to `1` if omitted.
|
|
2113
|
+
:arg _name:
|
|
2114
|
+
"""
|
|
2115
|
+
|
|
2116
|
+
name = "semantic"
|
|
2117
|
+
|
|
2118
|
+
def __init__(
|
|
2119
|
+
self,
|
|
2120
|
+
*,
|
|
2121
|
+
field: Union[str, "DefaultType"] = DEFAULT,
|
|
2122
|
+
query: Union[str, "DefaultType"] = DEFAULT,
|
|
2123
|
+
boost: Union[float, "DefaultType"] = DEFAULT,
|
|
2124
|
+
_name: Union[str, "DefaultType"] = DEFAULT,
|
|
2125
|
+
**kwargs: Any,
|
|
2126
|
+
):
|
|
2127
|
+
super().__init__(field=field, query=query, boost=boost, _name=_name, **kwargs)
|
|
2128
|
+
|
|
2129
|
+
|
|
2130
|
+
class Shape(Query):
|
|
2131
|
+
"""
|
|
2132
|
+
Queries documents that contain fields indexed using the `shape` type.
|
|
2133
|
+
|
|
2134
|
+
:arg _field: The field to use in this query.
|
|
2135
|
+
:arg _value: The query value for the field.
|
|
2136
|
+
:arg ignore_unmapped: When set to `true` the query ignores an unmapped
|
|
2137
|
+
field and will not match any documents.
|
|
2138
|
+
:arg boost: Floating point number used to decrease or increase the
|
|
2139
|
+
relevance scores of the query. Boost values are relative to the
|
|
2140
|
+
default value of 1.0. A boost value between 0 and 1.0 decreases
|
|
2141
|
+
the relevance score. A value greater than 1.0 increases the
|
|
2142
|
+
relevance score. Defaults to `1` if omitted.
|
|
2143
|
+
:arg _name:
|
|
2144
|
+
"""
|
|
2145
|
+
|
|
2146
|
+
name = "shape"
|
|
2147
|
+
|
|
2148
|
+
def __init__(
|
|
2149
|
+
self,
|
|
2150
|
+
_field: Union[str, "InstrumentedField", "DefaultType"] = DEFAULT,
|
|
2151
|
+
_value: Union["types.ShapeFieldQuery", Dict[str, Any], "DefaultType"] = DEFAULT,
|
|
2152
|
+
*,
|
|
2153
|
+
ignore_unmapped: Union[bool, "DefaultType"] = DEFAULT,
|
|
2154
|
+
boost: Union[float, "DefaultType"] = DEFAULT,
|
|
2155
|
+
_name: Union[str, "DefaultType"] = DEFAULT,
|
|
2156
|
+
**kwargs: Any,
|
|
2157
|
+
):
|
|
2158
|
+
if _field is not DEFAULT:
|
|
2159
|
+
kwargs[str(_field)] = _value
|
|
2160
|
+
super().__init__(
|
|
2161
|
+
ignore_unmapped=ignore_unmapped, boost=boost, _name=_name, **kwargs
|
|
2162
|
+
)
|
|
2163
|
+
|
|
2164
|
+
|
|
2165
|
+
class SimpleQueryString(Query):
|
|
2166
|
+
"""
|
|
2167
|
+
Returns documents based on a provided query string, using a parser
|
|
2168
|
+
with a limited but fault-tolerant syntax.
|
|
2169
|
+
|
|
2170
|
+
:arg query: (required) Query string in the simple query string syntax
|
|
2171
|
+
you wish to parse and use for search.
|
|
2172
|
+
:arg analyzer: Analyzer used to convert text in the query string into
|
|
2173
|
+
tokens.
|
|
2174
|
+
:arg analyze_wildcard: If `true`, the query attempts to analyze
|
|
2175
|
+
wildcard terms in the query string.
|
|
2176
|
+
:arg auto_generate_synonyms_phrase_query: If `true`, the parser
|
|
2177
|
+
creates a match_phrase query for each multi-position token.
|
|
2178
|
+
Defaults to `True` if omitted.
|
|
2179
|
+
:arg default_operator: Default boolean logic used to interpret text in
|
|
2180
|
+
the query string if no operators are specified. Defaults to `'or'`
|
|
2181
|
+
if omitted.
|
|
2182
|
+
:arg fields: Array of fields you wish to search. Accepts wildcard
|
|
2183
|
+
expressions. You also can boost relevance scores for matches to
|
|
2184
|
+
particular fields using a caret (`^`) notation. Defaults to the
|
|
2185
|
+
`index.query.default_field index` setting, which has a default
|
|
2186
|
+
value of `*`.
|
|
2187
|
+
:arg flags: List of enabled operators for the simple query string
|
|
2188
|
+
syntax. Defaults to `ALL` if omitted.
|
|
2189
|
+
:arg fuzzy_max_expansions: Maximum number of terms to which the query
|
|
2190
|
+
expands for fuzzy matching. Defaults to `50` if omitted.
|
|
2191
|
+
:arg fuzzy_prefix_length: Number of beginning characters left
|
|
2192
|
+
unchanged for fuzzy matching.
|
|
2193
|
+
:arg fuzzy_transpositions: If `true`, edits for fuzzy matching include
|
|
2194
|
+
transpositions of two adjacent characters (for example, `ab` to
|
|
2195
|
+
`ba`).
|
|
2196
|
+
:arg lenient: If `true`, format-based errors, such as providing a text
|
|
2197
|
+
value for a numeric field, are ignored.
|
|
2198
|
+
:arg minimum_should_match: Minimum number of clauses that must match
|
|
2199
|
+
for a document to be returned.
|
|
2200
|
+
:arg quote_field_suffix: Suffix appended to quoted text in the query
|
|
2201
|
+
string.
|
|
2202
|
+
:arg boost: Floating point number used to decrease or increase the
|
|
2203
|
+
relevance scores of the query. Boost values are relative to the
|
|
2204
|
+
default value of 1.0. A boost value between 0 and 1.0 decreases
|
|
2205
|
+
the relevance score. A value greater than 1.0 increases the
|
|
2206
|
+
relevance score. Defaults to `1` if omitted.
|
|
2207
|
+
:arg _name:
|
|
2208
|
+
"""
|
|
2209
|
+
|
|
2210
|
+
name = "simple_query_string"
|
|
2211
|
+
|
|
2212
|
+
def __init__(
|
|
2213
|
+
self,
|
|
2214
|
+
*,
|
|
2215
|
+
query: Union[str, "DefaultType"] = DEFAULT,
|
|
2216
|
+
analyzer: Union[str, "DefaultType"] = DEFAULT,
|
|
2217
|
+
analyze_wildcard: Union[bool, "DefaultType"] = DEFAULT,
|
|
2218
|
+
auto_generate_synonyms_phrase_query: Union[bool, "DefaultType"] = DEFAULT,
|
|
2219
|
+
default_operator: Union[Literal["and", "or"], "DefaultType"] = DEFAULT,
|
|
2220
|
+
fields: Union[
|
|
2221
|
+
Sequence[Union[str, "InstrumentedField"]], "DefaultType"
|
|
2222
|
+
] = DEFAULT,
|
|
2223
|
+
flags: Union[
|
|
2224
|
+
"types.PipeSeparatedFlags", Dict[str, Any], "DefaultType"
|
|
2225
|
+
] = DEFAULT,
|
|
2226
|
+
fuzzy_max_expansions: Union[int, "DefaultType"] = DEFAULT,
|
|
2227
|
+
fuzzy_prefix_length: Union[int, "DefaultType"] = DEFAULT,
|
|
2228
|
+
fuzzy_transpositions: Union[bool, "DefaultType"] = DEFAULT,
|
|
2229
|
+
lenient: Union[bool, "DefaultType"] = DEFAULT,
|
|
2230
|
+
minimum_should_match: Union[int, str, "DefaultType"] = DEFAULT,
|
|
2231
|
+
quote_field_suffix: Union[str, "DefaultType"] = DEFAULT,
|
|
2232
|
+
boost: Union[float, "DefaultType"] = DEFAULT,
|
|
2233
|
+
_name: Union[str, "DefaultType"] = DEFAULT,
|
|
2234
|
+
**kwargs: Any,
|
|
2235
|
+
):
|
|
2236
|
+
super().__init__(
|
|
2237
|
+
query=query,
|
|
2238
|
+
analyzer=analyzer,
|
|
2239
|
+
analyze_wildcard=analyze_wildcard,
|
|
2240
|
+
auto_generate_synonyms_phrase_query=auto_generate_synonyms_phrase_query,
|
|
2241
|
+
default_operator=default_operator,
|
|
2242
|
+
fields=fields,
|
|
2243
|
+
flags=flags,
|
|
2244
|
+
fuzzy_max_expansions=fuzzy_max_expansions,
|
|
2245
|
+
fuzzy_prefix_length=fuzzy_prefix_length,
|
|
2246
|
+
fuzzy_transpositions=fuzzy_transpositions,
|
|
2247
|
+
lenient=lenient,
|
|
2248
|
+
minimum_should_match=minimum_should_match,
|
|
2249
|
+
quote_field_suffix=quote_field_suffix,
|
|
2250
|
+
boost=boost,
|
|
2251
|
+
_name=_name,
|
|
2252
|
+
**kwargs,
|
|
2253
|
+
)
|
|
2254
|
+
|
|
2255
|
+
|
|
2256
|
+
class SpanContaining(Query):
|
|
2257
|
+
"""
|
|
2258
|
+
Returns matches which enclose another span query.
|
|
2259
|
+
|
|
2260
|
+
:arg big: (required) Can be any span query. Matching spans from `big`
|
|
2261
|
+
that contain matches from `little` are returned.
|
|
2262
|
+
:arg little: (required) Can be any span query. Matching spans from
|
|
2263
|
+
`big` that contain matches from `little` are returned.
|
|
2264
|
+
:arg boost: Floating point number used to decrease or increase the
|
|
2265
|
+
relevance scores of the query. Boost values are relative to the
|
|
2266
|
+
default value of 1.0. A boost value between 0 and 1.0 decreases
|
|
2267
|
+
the relevance score. A value greater than 1.0 increases the
|
|
2268
|
+
relevance score. Defaults to `1` if omitted.
|
|
2269
|
+
:arg _name:
|
|
2270
|
+
"""
|
|
2271
|
+
|
|
2272
|
+
name = "span_containing"
|
|
2273
|
+
|
|
2274
|
+
def __init__(
|
|
2275
|
+
self,
|
|
2276
|
+
*,
|
|
2277
|
+
big: Union["types.SpanQuery", Dict[str, Any], "DefaultType"] = DEFAULT,
|
|
2278
|
+
little: Union["types.SpanQuery", Dict[str, Any], "DefaultType"] = DEFAULT,
|
|
2279
|
+
boost: Union[float, "DefaultType"] = DEFAULT,
|
|
2280
|
+
_name: Union[str, "DefaultType"] = DEFAULT,
|
|
2281
|
+
**kwargs: Any,
|
|
2282
|
+
):
|
|
2283
|
+
super().__init__(big=big, little=little, boost=boost, _name=_name, **kwargs)
|
|
2284
|
+
|
|
2285
|
+
|
|
2286
|
+
class SpanFieldMasking(Query):
|
|
2287
|
+
"""
|
|
2288
|
+
Wrapper to allow span queries to participate in composite single-field
|
|
2289
|
+
span queries by _lying_ about their search field.
|
|
2290
|
+
|
|
2291
|
+
:arg field: (required)
|
|
2292
|
+
:arg query: (required)
|
|
2293
|
+
:arg boost: Floating point number used to decrease or increase the
|
|
2294
|
+
relevance scores of the query. Boost values are relative to the
|
|
2295
|
+
default value of 1.0. A boost value between 0 and 1.0 decreases
|
|
2296
|
+
the relevance score. A value greater than 1.0 increases the
|
|
2297
|
+
relevance score. Defaults to `1` if omitted.
|
|
2298
|
+
:arg _name:
|
|
2299
|
+
"""
|
|
2300
|
+
|
|
2301
|
+
name = "span_field_masking"
|
|
2302
|
+
|
|
2303
|
+
def __init__(
|
|
2304
|
+
self,
|
|
2305
|
+
*,
|
|
2306
|
+
field: Union[str, "InstrumentedField", "DefaultType"] = DEFAULT,
|
|
2307
|
+
query: Union["types.SpanQuery", Dict[str, Any], "DefaultType"] = DEFAULT,
|
|
2308
|
+
boost: Union[float, "DefaultType"] = DEFAULT,
|
|
2309
|
+
_name: Union[str, "DefaultType"] = DEFAULT,
|
|
2310
|
+
**kwargs: Any,
|
|
2311
|
+
):
|
|
2312
|
+
super().__init__(field=field, query=query, boost=boost, _name=_name, **kwargs)
|
|
2313
|
+
|
|
2314
|
+
|
|
2315
|
+
class SpanFirst(Query):
|
|
2316
|
+
"""
|
|
2317
|
+
Matches spans near the beginning of a field.
|
|
2318
|
+
|
|
2319
|
+
:arg end: (required) Controls the maximum end position permitted in a
|
|
2320
|
+
match.
|
|
2321
|
+
:arg match: (required) Can be any other span type query.
|
|
2322
|
+
:arg boost: Floating point number used to decrease or increase the
|
|
2323
|
+
relevance scores of the query. Boost values are relative to the
|
|
2324
|
+
default value of 1.0. A boost value between 0 and 1.0 decreases
|
|
2325
|
+
the relevance score. A value greater than 1.0 increases the
|
|
2326
|
+
relevance score. Defaults to `1` if omitted.
|
|
2327
|
+
:arg _name:
|
|
2328
|
+
"""
|
|
2329
|
+
|
|
2330
|
+
name = "span_first"
|
|
2331
|
+
|
|
2332
|
+
def __init__(
|
|
2333
|
+
self,
|
|
2334
|
+
*,
|
|
2335
|
+
end: Union[int, "DefaultType"] = DEFAULT,
|
|
2336
|
+
match: Union["types.SpanQuery", Dict[str, Any], "DefaultType"] = DEFAULT,
|
|
2337
|
+
boost: Union[float, "DefaultType"] = DEFAULT,
|
|
2338
|
+
_name: Union[str, "DefaultType"] = DEFAULT,
|
|
2339
|
+
**kwargs: Any,
|
|
2340
|
+
):
|
|
2341
|
+
super().__init__(end=end, match=match, boost=boost, _name=_name, **kwargs)
|
|
2342
|
+
|
|
2343
|
+
|
|
2344
|
+
class SpanMulti(Query):
|
|
2345
|
+
"""
|
|
2346
|
+
Allows you to wrap a multi term query (one of `wildcard`, `fuzzy`,
|
|
2347
|
+
`prefix`, `range`, or `regexp` query) as a `span` query, so it can be
|
|
2348
|
+
nested.
|
|
2349
|
+
|
|
2350
|
+
:arg match: (required) Should be a multi term query (one of
|
|
2351
|
+
`wildcard`, `fuzzy`, `prefix`, `range`, or `regexp` query).
|
|
2352
|
+
:arg boost: Floating point number used to decrease or increase the
|
|
2353
|
+
relevance scores of the query. Boost values are relative to the
|
|
2354
|
+
default value of 1.0. A boost value between 0 and 1.0 decreases
|
|
2355
|
+
the relevance score. A value greater than 1.0 increases the
|
|
2356
|
+
relevance score. Defaults to `1` if omitted.
|
|
2357
|
+
:arg _name:
|
|
2358
|
+
"""
|
|
2359
|
+
|
|
2360
|
+
name = "span_multi"
|
|
2361
|
+
_param_defs = {
|
|
2362
|
+
"match": {"type": "query"},
|
|
2363
|
+
}
|
|
2364
|
+
|
|
2365
|
+
def __init__(
|
|
2366
|
+
self,
|
|
2367
|
+
*,
|
|
2368
|
+
match: Union[Query, "DefaultType"] = DEFAULT,
|
|
2369
|
+
boost: Union[float, "DefaultType"] = DEFAULT,
|
|
2370
|
+
_name: Union[str, "DefaultType"] = DEFAULT,
|
|
2371
|
+
**kwargs: Any,
|
|
2372
|
+
):
|
|
2373
|
+
super().__init__(match=match, boost=boost, _name=_name, **kwargs)
|
|
2374
|
+
|
|
2375
|
+
|
|
2376
|
+
class SpanNear(Query):
|
|
2377
|
+
"""
|
|
2378
|
+
Matches spans which are near one another. You can specify `slop`, the
|
|
2379
|
+
maximum number of intervening unmatched positions, as well as whether
|
|
2380
|
+
matches are required to be in-order.
|
|
2381
|
+
|
|
2382
|
+
:arg clauses: (required) Array of one or more other span type queries.
|
|
2383
|
+
:arg in_order: Controls whether matches are required to be in-order.
|
|
2384
|
+
:arg slop: Controls the maximum number of intervening unmatched
|
|
2385
|
+
positions permitted.
|
|
2386
|
+
:arg boost: Floating point number used to decrease or increase the
|
|
2387
|
+
relevance scores of the query. Boost values are relative to the
|
|
2388
|
+
default value of 1.0. A boost value between 0 and 1.0 decreases
|
|
2389
|
+
the relevance score. A value greater than 1.0 increases the
|
|
2390
|
+
relevance score. Defaults to `1` if omitted.
|
|
2391
|
+
:arg _name:
|
|
2392
|
+
"""
|
|
2393
|
+
|
|
2394
|
+
name = "span_near"
|
|
2395
|
+
|
|
2396
|
+
def __init__(
|
|
2397
|
+
self,
|
|
2398
|
+
*,
|
|
2399
|
+
clauses: Union[
|
|
2400
|
+
Sequence["types.SpanQuery"], Sequence[Dict[str, Any]], "DefaultType"
|
|
2401
|
+
] = DEFAULT,
|
|
2402
|
+
in_order: Union[bool, "DefaultType"] = DEFAULT,
|
|
2403
|
+
slop: Union[int, "DefaultType"] = DEFAULT,
|
|
2404
|
+
boost: Union[float, "DefaultType"] = DEFAULT,
|
|
2405
|
+
_name: Union[str, "DefaultType"] = DEFAULT,
|
|
2406
|
+
**kwargs: Any,
|
|
2407
|
+
):
|
|
2408
|
+
super().__init__(
|
|
2409
|
+
clauses=clauses,
|
|
2410
|
+
in_order=in_order,
|
|
2411
|
+
slop=slop,
|
|
2412
|
+
boost=boost,
|
|
2413
|
+
_name=_name,
|
|
2414
|
+
**kwargs,
|
|
2415
|
+
)
|
|
2416
|
+
|
|
2417
|
+
|
|
2418
|
+
class SpanNot(Query):
|
|
2419
|
+
"""
|
|
2420
|
+
Removes matches which overlap with another span query or which are
|
|
2421
|
+
within x tokens before (controlled by the parameter `pre`) or y tokens
|
|
2422
|
+
after (controlled by the parameter `post`) another span query.
|
|
2423
|
+
|
|
2424
|
+
:arg exclude: (required) Span query whose matches must not overlap
|
|
2425
|
+
those returned.
|
|
2426
|
+
:arg include: (required) Span query whose matches are filtered.
|
|
2427
|
+
:arg dist: The number of tokens from within the include span that
|
|
2428
|
+
can’t have overlap with the exclude span. Equivalent to setting
|
|
2429
|
+
both `pre` and `post`.
|
|
2430
|
+
:arg post: The number of tokens after the include span that can’t have
|
|
2431
|
+
overlap with the exclude span.
|
|
2432
|
+
:arg pre: The number of tokens before the include span that can’t have
|
|
2433
|
+
overlap with the exclude span.
|
|
2434
|
+
:arg boost: Floating point number used to decrease or increase the
|
|
2435
|
+
relevance scores of the query. Boost values are relative to the
|
|
2436
|
+
default value of 1.0. A boost value between 0 and 1.0 decreases
|
|
2437
|
+
the relevance score. A value greater than 1.0 increases the
|
|
2438
|
+
relevance score. Defaults to `1` if omitted.
|
|
2439
|
+
:arg _name:
|
|
2440
|
+
"""
|
|
2441
|
+
|
|
2442
|
+
name = "span_not"
|
|
2443
|
+
|
|
2444
|
+
def __init__(
|
|
2445
|
+
self,
|
|
2446
|
+
*,
|
|
2447
|
+
exclude: Union["types.SpanQuery", Dict[str, Any], "DefaultType"] = DEFAULT,
|
|
2448
|
+
include: Union["types.SpanQuery", Dict[str, Any], "DefaultType"] = DEFAULT,
|
|
2449
|
+
dist: Union[int, "DefaultType"] = DEFAULT,
|
|
2450
|
+
post: Union[int, "DefaultType"] = DEFAULT,
|
|
2451
|
+
pre: Union[int, "DefaultType"] = DEFAULT,
|
|
2452
|
+
boost: Union[float, "DefaultType"] = DEFAULT,
|
|
2453
|
+
_name: Union[str, "DefaultType"] = DEFAULT,
|
|
2454
|
+
**kwargs: Any,
|
|
2455
|
+
):
|
|
2456
|
+
super().__init__(
|
|
2457
|
+
exclude=exclude,
|
|
2458
|
+
include=include,
|
|
2459
|
+
dist=dist,
|
|
2460
|
+
post=post,
|
|
2461
|
+
pre=pre,
|
|
2462
|
+
boost=boost,
|
|
2463
|
+
_name=_name,
|
|
2464
|
+
**kwargs,
|
|
2465
|
+
)
|
|
2466
|
+
|
|
2467
|
+
|
|
2468
|
+
class SpanOr(Query):
|
|
2469
|
+
"""
|
|
2470
|
+
Matches the union of its span clauses.
|
|
2471
|
+
|
|
2472
|
+
:arg clauses: (required) Array of one or more other span type queries.
|
|
2473
|
+
:arg boost: Floating point number used to decrease or increase the
|
|
2474
|
+
relevance scores of the query. Boost values are relative to the
|
|
2475
|
+
default value of 1.0. A boost value between 0 and 1.0 decreases
|
|
2476
|
+
the relevance score. A value greater than 1.0 increases the
|
|
2477
|
+
relevance score. Defaults to `1` if omitted.
|
|
2478
|
+
:arg _name:
|
|
2479
|
+
"""
|
|
2480
|
+
|
|
2481
|
+
name = "span_or"
|
|
2482
|
+
|
|
2483
|
+
def __init__(
|
|
2484
|
+
self,
|
|
2485
|
+
*,
|
|
2486
|
+
clauses: Union[
|
|
2487
|
+
Sequence["types.SpanQuery"], Sequence[Dict[str, Any]], "DefaultType"
|
|
2488
|
+
] = DEFAULT,
|
|
2489
|
+
boost: Union[float, "DefaultType"] = DEFAULT,
|
|
2490
|
+
_name: Union[str, "DefaultType"] = DEFAULT,
|
|
2491
|
+
**kwargs: Any,
|
|
2492
|
+
):
|
|
2493
|
+
super().__init__(clauses=clauses, boost=boost, _name=_name, **kwargs)
|
|
2494
|
+
|
|
2495
|
+
|
|
2496
|
+
class SpanTerm(Query):
|
|
2497
|
+
"""
|
|
2498
|
+
Matches spans containing a term.
|
|
2499
|
+
|
|
2500
|
+
:arg _field: The field to use in this query.
|
|
2501
|
+
:arg _value: The query value for the field.
|
|
2502
|
+
"""
|
|
2503
|
+
|
|
2504
|
+
name = "span_term"
|
|
2505
|
+
|
|
2506
|
+
def __init__(
|
|
2507
|
+
self,
|
|
2508
|
+
_field: Union[str, "InstrumentedField", "DefaultType"] = DEFAULT,
|
|
2509
|
+
_value: Union["types.SpanTermQuery", Dict[str, Any], "DefaultType"] = DEFAULT,
|
|
2510
|
+
**kwargs: Any,
|
|
2511
|
+
):
|
|
2512
|
+
if _field is not DEFAULT:
|
|
2513
|
+
kwargs[str(_field)] = _value
|
|
2514
|
+
super().__init__(**kwargs)
|
|
2515
|
+
|
|
2516
|
+
|
|
2517
|
+
class SpanWithin(Query):
|
|
2518
|
+
"""
|
|
2519
|
+
Returns matches which are enclosed inside another span query.
|
|
2520
|
+
|
|
2521
|
+
:arg big: (required) Can be any span query. Matching spans from
|
|
2522
|
+
`little` that are enclosed within `big` are returned.
|
|
2523
|
+
:arg little: (required) Can be any span query. Matching spans from
|
|
2524
|
+
`little` that are enclosed within `big` are returned.
|
|
2525
|
+
:arg boost: Floating point number used to decrease or increase the
|
|
2526
|
+
relevance scores of the query. Boost values are relative to the
|
|
2527
|
+
default value of 1.0. A boost value between 0 and 1.0 decreases
|
|
2528
|
+
the relevance score. A value greater than 1.0 increases the
|
|
2529
|
+
relevance score. Defaults to `1` if omitted.
|
|
2530
|
+
:arg _name:
|
|
2531
|
+
"""
|
|
2532
|
+
|
|
2533
|
+
name = "span_within"
|
|
2534
|
+
|
|
2535
|
+
def __init__(
|
|
2536
|
+
self,
|
|
2537
|
+
*,
|
|
2538
|
+
big: Union["types.SpanQuery", Dict[str, Any], "DefaultType"] = DEFAULT,
|
|
2539
|
+
little: Union["types.SpanQuery", Dict[str, Any], "DefaultType"] = DEFAULT,
|
|
2540
|
+
boost: Union[float, "DefaultType"] = DEFAULT,
|
|
2541
|
+
_name: Union[str, "DefaultType"] = DEFAULT,
|
|
2542
|
+
**kwargs: Any,
|
|
2543
|
+
):
|
|
2544
|
+
super().__init__(big=big, little=little, boost=boost, _name=_name, **kwargs)
|
|
2545
|
+
|
|
2546
|
+
|
|
2547
|
+
class SparseVector(Query):
|
|
2548
|
+
"""
|
|
2549
|
+
Using input query vectors or a natural language processing model to
|
|
2550
|
+
convert a query into a list of token-weight pairs, queries against a
|
|
2551
|
+
sparse vector field.
|
|
2552
|
+
|
|
2553
|
+
:arg field: (required) The name of the field that contains the token-
|
|
2554
|
+
weight pairs to be searched against. This field must be a mapped
|
|
2555
|
+
sparse_vector field.
|
|
2556
|
+
:arg query_vector: Dictionary of precomputed sparse vectors and their
|
|
2557
|
+
associated weights. Only one of inference_id or query_vector may
|
|
2558
|
+
be supplied in a request.
|
|
2559
|
+
:arg inference_id: The inference ID to use to convert the query text
|
|
2560
|
+
into token-weight pairs. It must be the same inference ID that was
|
|
2561
|
+
used to create the tokens from the input text. Only one of
|
|
2562
|
+
inference_id and query_vector is allowed. If inference_id is
|
|
2563
|
+
specified, query must also be specified. Only one of inference_id
|
|
2564
|
+
or query_vector may be supplied in a request.
|
|
2565
|
+
:arg query: The query text you want to use for search. If inference_id
|
|
2566
|
+
is specified, query must also be specified.
|
|
2567
|
+
:arg prune: Whether to perform pruning, omitting the non-significant
|
|
2568
|
+
tokens from the query to improve query performance. If prune is
|
|
2569
|
+
true but the pruning_config is not specified, pruning will occur
|
|
2570
|
+
but default values will be used. Default: false
|
|
2571
|
+
:arg pruning_config: Optional pruning configuration. If enabled, this
|
|
2572
|
+
will omit non-significant tokens from the query in order to
|
|
2573
|
+
improve query performance. This is only used if prune is set to
|
|
2574
|
+
true. If prune is set to true but pruning_config is not specified,
|
|
2575
|
+
default values will be used.
|
|
2576
|
+
:arg boost: Floating point number used to decrease or increase the
|
|
2577
|
+
relevance scores of the query. Boost values are relative to the
|
|
2578
|
+
default value of 1.0. A boost value between 0 and 1.0 decreases
|
|
2579
|
+
the relevance score. A value greater than 1.0 increases the
|
|
2580
|
+
relevance score. Defaults to `1` if omitted.
|
|
2581
|
+
:arg _name:
|
|
2582
|
+
"""
|
|
2583
|
+
|
|
2584
|
+
name = "sparse_vector"
|
|
2585
|
+
|
|
2586
|
+
def __init__(
|
|
2587
|
+
self,
|
|
2588
|
+
*,
|
|
2589
|
+
field: Union[str, "InstrumentedField", "DefaultType"] = DEFAULT,
|
|
2590
|
+
query_vector: Union[Mapping[str, float], "DefaultType"] = DEFAULT,
|
|
2591
|
+
inference_id: Union[str, "DefaultType"] = DEFAULT,
|
|
2592
|
+
query: Union[str, "DefaultType"] = DEFAULT,
|
|
2593
|
+
prune: Union[bool, "DefaultType"] = DEFAULT,
|
|
2594
|
+
pruning_config: Union[
|
|
2595
|
+
"types.TokenPruningConfig", Dict[str, Any], "DefaultType"
|
|
2596
|
+
] = DEFAULT,
|
|
2597
|
+
boost: Union[float, "DefaultType"] = DEFAULT,
|
|
2598
|
+
_name: Union[str, "DefaultType"] = DEFAULT,
|
|
2599
|
+
**kwargs: Any,
|
|
2600
|
+
):
|
|
2601
|
+
super().__init__(
|
|
2602
|
+
field=field,
|
|
2603
|
+
query_vector=query_vector,
|
|
2604
|
+
inference_id=inference_id,
|
|
2605
|
+
query=query,
|
|
2606
|
+
prune=prune,
|
|
2607
|
+
pruning_config=pruning_config,
|
|
2608
|
+
boost=boost,
|
|
2609
|
+
_name=_name,
|
|
2610
|
+
**kwargs,
|
|
2611
|
+
)
|
|
2612
|
+
|
|
2613
|
+
|
|
2614
|
+
class Term(Query):
|
|
2615
|
+
"""
|
|
2616
|
+
Returns documents that contain an exact term in a provided field. To
|
|
2617
|
+
return a document, the query term must exactly match the queried
|
|
2618
|
+
field's value, including whitespace and capitalization.
|
|
2619
|
+
|
|
2620
|
+
:arg _field: The field to use in this query.
|
|
2621
|
+
:arg _value: The query value for the field.
|
|
2622
|
+
"""
|
|
2623
|
+
|
|
2624
|
+
name = "term"
|
|
2625
|
+
|
|
2626
|
+
def __init__(
|
|
2627
|
+
self,
|
|
2628
|
+
_field: Union[str, "InstrumentedField", "DefaultType"] = DEFAULT,
|
|
2629
|
+
_value: Union["types.TermQuery", Dict[str, Any], "DefaultType"] = DEFAULT,
|
|
2630
|
+
**kwargs: Any,
|
|
2631
|
+
):
|
|
2632
|
+
if _field is not DEFAULT:
|
|
2633
|
+
kwargs[str(_field)] = _value
|
|
2634
|
+
super().__init__(**kwargs)
|
|
2635
|
+
|
|
2636
|
+
|
|
2637
|
+
class Terms(Query):
|
|
2638
|
+
"""
|
|
2639
|
+
Returns documents that contain one or more exact terms in a provided
|
|
2640
|
+
field. To return a document, one or more terms must exactly match a
|
|
2641
|
+
field value, including whitespace and capitalization.
|
|
2642
|
+
|
|
2643
|
+
:arg _field: The field to use in this query.
|
|
2644
|
+
:arg _value: The query value for the field.
|
|
2645
|
+
:arg boost: Floating point number used to decrease or increase the
|
|
2646
|
+
relevance scores of the query. Boost values are relative to the
|
|
2647
|
+
default value of 1.0. A boost value between 0 and 1.0 decreases
|
|
2648
|
+
the relevance score. A value greater than 1.0 increases the
|
|
2649
|
+
relevance score. Defaults to `1` if omitted.
|
|
2650
|
+
:arg _name:
|
|
2651
|
+
"""
|
|
2652
|
+
|
|
2653
|
+
name = "terms"
|
|
2654
|
+
|
|
2655
|
+
def __init__(
|
|
2656
|
+
self,
|
|
2657
|
+
_field: Union[str, "InstrumentedField", "DefaultType"] = DEFAULT,
|
|
2658
|
+
_value: Union[
|
|
2659
|
+
Sequence[Union[int, float, str, bool, None, Any]],
|
|
2660
|
+
"types.TermsLookup",
|
|
2661
|
+
Dict[str, Any],
|
|
2662
|
+
"DefaultType",
|
|
2663
|
+
] = DEFAULT,
|
|
2664
|
+
*,
|
|
2665
|
+
boost: Union[float, "DefaultType"] = DEFAULT,
|
|
2666
|
+
_name: Union[str, "DefaultType"] = DEFAULT,
|
|
2667
|
+
**kwargs: Any,
|
|
2668
|
+
):
|
|
2669
|
+
if _field is not DEFAULT:
|
|
2670
|
+
kwargs[str(_field)] = _value
|
|
2671
|
+
super().__init__(boost=boost, _name=_name, **kwargs)
|
|
2672
|
+
|
|
2673
|
+
def _setattr(self, name: str, value: Any) -> None:
|
|
2674
|
+
# here we convert any iterables that are not strings to lists
|
|
2675
|
+
if hasattr(value, "__iter__") and not isinstance(value, (str, list, dict)):
|
|
2676
|
+
value = list(value)
|
|
2677
|
+
super()._setattr(name, value)
|
|
2678
|
+
|
|
2679
|
+
|
|
2680
|
+
class TermsSet(Query):
|
|
2681
|
+
"""
|
|
2682
|
+
Returns documents that contain a minimum number of exact terms in a
|
|
2683
|
+
provided field. To return a document, a required number of terms must
|
|
2684
|
+
exactly match the field values, including whitespace and
|
|
2685
|
+
capitalization.
|
|
2686
|
+
|
|
2687
|
+
:arg _field: The field to use in this query.
|
|
2688
|
+
:arg _value: The query value for the field.
|
|
2689
|
+
"""
|
|
2690
|
+
|
|
2691
|
+
name = "terms_set"
|
|
2692
|
+
|
|
2693
|
+
def __init__(
|
|
2694
|
+
self,
|
|
2695
|
+
_field: Union[str, "InstrumentedField", "DefaultType"] = DEFAULT,
|
|
2696
|
+
_value: Union["types.TermsSetQuery", Dict[str, Any], "DefaultType"] = DEFAULT,
|
|
2697
|
+
**kwargs: Any,
|
|
2698
|
+
):
|
|
2699
|
+
if _field is not DEFAULT:
|
|
2700
|
+
kwargs[str(_field)] = _value
|
|
2701
|
+
super().__init__(**kwargs)
|
|
2702
|
+
|
|
2703
|
+
|
|
2704
|
+
class TextExpansion(Query):
|
|
2705
|
+
"""
|
|
2706
|
+
Uses a natural language processing model to convert the query text
|
|
2707
|
+
into a list of token-weight pairs which are then used in a query
|
|
2708
|
+
against a sparse vector or rank features field.
|
|
2709
|
+
|
|
2710
|
+
:arg _field: The field to use in this query.
|
|
2711
|
+
:arg _value: The query value for the field.
|
|
2712
|
+
"""
|
|
2713
|
+
|
|
2714
|
+
name = "text_expansion"
|
|
2715
|
+
|
|
2716
|
+
def __init__(
|
|
2717
|
+
self,
|
|
2718
|
+
_field: Union[str, "InstrumentedField", "DefaultType"] = DEFAULT,
|
|
2719
|
+
_value: Union[
|
|
2720
|
+
"types.TextExpansionQuery", Dict[str, Any], "DefaultType"
|
|
2721
|
+
] = DEFAULT,
|
|
2722
|
+
**kwargs: Any,
|
|
2723
|
+
):
|
|
2724
|
+
if _field is not DEFAULT:
|
|
2725
|
+
kwargs[str(_field)] = _value
|
|
2726
|
+
super().__init__(**kwargs)
|
|
2727
|
+
|
|
2728
|
+
|
|
2729
|
+
class WeightedTokens(Query):
|
|
2730
|
+
"""
|
|
2731
|
+
Supports returning text_expansion query results by sending in
|
|
2732
|
+
precomputed tokens with the query.
|
|
2733
|
+
|
|
2734
|
+
:arg _field: The field to use in this query.
|
|
2735
|
+
:arg _value: The query value for the field.
|
|
2736
|
+
"""
|
|
2737
|
+
|
|
2738
|
+
name = "weighted_tokens"
|
|
2739
|
+
|
|
2740
|
+
def __init__(
|
|
2741
|
+
self,
|
|
2742
|
+
_field: Union[str, "InstrumentedField", "DefaultType"] = DEFAULT,
|
|
2743
|
+
_value: Union[
|
|
2744
|
+
"types.WeightedTokensQuery", Dict[str, Any], "DefaultType"
|
|
2745
|
+
] = DEFAULT,
|
|
2746
|
+
**kwargs: Any,
|
|
2747
|
+
):
|
|
2748
|
+
if _field is not DEFAULT:
|
|
2749
|
+
kwargs[str(_field)] = _value
|
|
2750
|
+
super().__init__(**kwargs)
|
|
2751
|
+
|
|
2752
|
+
|
|
2753
|
+
class Wildcard(Query):
|
|
2754
|
+
"""
|
|
2755
|
+
Returns documents that contain terms matching a wildcard pattern.
|
|
2756
|
+
|
|
2757
|
+
:arg _field: The field to use in this query.
|
|
2758
|
+
:arg _value: The query value for the field.
|
|
2759
|
+
"""
|
|
2760
|
+
|
|
2761
|
+
name = "wildcard"
|
|
2762
|
+
|
|
2763
|
+
def __init__(
|
|
2764
|
+
self,
|
|
2765
|
+
_field: Union[str, "InstrumentedField", "DefaultType"] = DEFAULT,
|
|
2766
|
+
_value: Union["types.WildcardQuery", Dict[str, Any], "DefaultType"] = DEFAULT,
|
|
2767
|
+
**kwargs: Any,
|
|
2768
|
+
):
|
|
2769
|
+
if _field is not DEFAULT:
|
|
2770
|
+
kwargs[str(_field)] = _value
|
|
2771
|
+
super().__init__(**kwargs)
|
|
2772
|
+
|
|
2773
|
+
|
|
2774
|
+
class Wrapper(Query):
|
|
2775
|
+
"""
|
|
2776
|
+
A query that accepts any other query as base64 encoded string.
|
|
2777
|
+
|
|
2778
|
+
:arg query: (required) A base64 encoded query. The binary data format
|
|
2779
|
+
can be any of JSON, YAML, CBOR or SMILE encodings
|
|
2780
|
+
:arg boost: Floating point number used to decrease or increase the
|
|
2781
|
+
relevance scores of the query. Boost values are relative to the
|
|
2782
|
+
default value of 1.0. A boost value between 0 and 1.0 decreases
|
|
2783
|
+
the relevance score. A value greater than 1.0 increases the
|
|
2784
|
+
relevance score. Defaults to `1` if omitted.
|
|
2785
|
+
:arg _name:
|
|
2786
|
+
"""
|
|
2787
|
+
|
|
2788
|
+
name = "wrapper"
|
|
2789
|
+
|
|
2790
|
+
def __init__(
|
|
2791
|
+
self,
|
|
2792
|
+
*,
|
|
2793
|
+
query: Union[str, "DefaultType"] = DEFAULT,
|
|
2794
|
+
boost: Union[float, "DefaultType"] = DEFAULT,
|
|
2795
|
+
_name: Union[str, "DefaultType"] = DEFAULT,
|
|
2796
|
+
**kwargs: Any,
|
|
2797
|
+
):
|
|
2798
|
+
super().__init__(query=query, boost=boost, _name=_name, **kwargs)
|
|
2799
|
+
|
|
2800
|
+
|
|
2801
|
+
class Type(Query):
|
|
2802
|
+
"""
|
|
2803
|
+
:arg value: (required)
|
|
2804
|
+
:arg boost: Floating point number used to decrease or increase the
|
|
2805
|
+
relevance scores of the query. Boost values are relative to the
|
|
2806
|
+
default value of 1.0. A boost value between 0 and 1.0 decreases
|
|
2807
|
+
the relevance score. A value greater than 1.0 increases the
|
|
2808
|
+
relevance score. Defaults to `1` if omitted.
|
|
2809
|
+
:arg _name:
|
|
2810
|
+
"""
|
|
2811
|
+
|
|
2812
|
+
name = "type"
|
|
2813
|
+
|
|
2814
|
+
def __init__(
|
|
2815
|
+
self,
|
|
2816
|
+
*,
|
|
2817
|
+
value: Union[str, "DefaultType"] = DEFAULT,
|
|
2818
|
+
boost: Union[float, "DefaultType"] = DEFAULT,
|
|
2819
|
+
_name: Union[str, "DefaultType"] = DEFAULT,
|
|
2820
|
+
**kwargs: Any,
|
|
2821
|
+
):
|
|
2822
|
+
super().__init__(value=value, boost=boost, _name=_name, **kwargs)
|