Skip to content

Commit e2919e2

Browse files
miguelgrinberggithub-actions[bot]
authored andcommitted
Add Elasticsearch-DSL code (#2736)
* Add Elasticsearch-DSL code * reformat code * runasync dsl * dsl generator * fix pytest configuration * dsl testing fixes * wipe cluster after dsl tests * remove unused coverage option * review feedback * 2nd round of feedback addressed * fix coverage reports (cherry picked from commit 10ded22)
1 parent f04755d commit e2919e2

File tree

139 files changed

+40147
-15
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

139 files changed

+40147
-15
lines changed

‎elasticsearch/__init__.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -27,15 +27,15 @@
2727
from ._version import __versionstr__
2828

2929
# Ensure that a compatible version of elastic-transport is installed.
30-
_version_groups = tuple(int(x) for x in re.search(r"^(\d+)\.(\d+)\.(\d+)", _elastic_transport_version).groups()) # type: ignore
30+
_version_groups = tuple(int(x) for x in re.search(r"^(\d+)\.(\d+)\.(\d+)", _elastic_transport_version).groups()) # type: ignore[union-attr]
3131
if _version_groups < (8, 0, 0) or _version_groups > (9, 0, 0):
3232
raise ImportError(
3333
"An incompatible version of elastic-transport is installed. Must be between "
3434
"v8.0.0 and v9.0.0. Install the correct version with the following command: "
3535
"$ python -m pip install 'elastic-transport>=8, <9'"
3636
)
3737

38-
_version_groups = re.search(r"^(\d+)\.(\d+)\.(\d+)", __versionstr__).groups() # type: ignore
38+
_version_groups = re.search(r"^(\d+)\.(\d+)\.(\d+)", __versionstr__).groups() # type: ignore[assignment, union-attr]
3939
_major, _minor, _patch = (int(x) for x in _version_groups)
4040
VERSION = __version__ = (_major, _minor, _patch)
4141

‎elasticsearch/_async/helpers.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,7 @@ async def map_actions() -> AsyncIterable[_TYPE_BULK_ACTION_HEADER_AND_BODY]:
257257
]
258258
ok: bool
259259
info: Dict[str, Any]
260-
async for data, (ok, info) in azip( # type: ignore
260+
async for data, (ok, info) in azip( # type: ignore[assignment, misc]
261261
bulk_data,
262262
_process_bulk_chunk(
263263
client,

‎elasticsearch/_sync/client/utils.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,7 @@ def host_mapping_to_node_config(host: Mapping[str, Union[str, int]]) -> NodeConf
232232
)
233233
options["path_prefix"] = options.pop("url_prefix")
234234

235-
return NodeConfig(**options) # type: ignore
235+
return NodeConfig(**options) # type: ignore[arg-type]
236236

237237

238238
def cloud_id_to_node_configs(cloud_id: str) -> List[NodeConfig]:

‎elasticsearch/dsl/__init__.py

+203
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,203 @@
1+
# Licensed to Elasticsearch B.V. under one or more contributor
2+
# license agreements. See the NOTICE file distributed with
3+
# this work for additional information regarding copyright
4+
# ownership. Elasticsearch B.V. licenses this file to you under
5+
# the Apache License, Version 2.0 (the "License"); you may
6+
# not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing,
12+
# software distributed under the License is distributed on an
13+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
# KIND, either express or implied. See the License for the
15+
# specific language governing permissions and limitations
16+
# under the License.
17+
18+
from . import async_connections, connections
19+
from .aggs import A, Agg
20+
from .analysis import analyzer, char_filter, normalizer, token_filter, tokenizer
21+
from .document import AsyncDocument, Document
22+
from .document_base import InnerDoc, M, MetaField, mapped_field
23+
from .exceptions import (
24+
ElasticsearchDslException,
25+
IllegalOperation,
26+
UnknownDslObject,
27+
ValidationException,
28+
)
29+
from .faceted_search import (
30+
AsyncFacetedSearch,
31+
DateHistogramFacet,
32+
Facet,
33+
FacetedResponse,
34+
FacetedSearch,
35+
HistogramFacet,
36+
NestedFacet,
37+
RangeFacet,
38+
TermsFacet,
39+
)
40+
from .field import (
41+
Binary,
42+
Boolean,
43+
Byte,
44+
Completion,
45+
ConstantKeyword,
46+
CustomField,
47+
Date,
48+
DateRange,
49+
DenseVector,
50+
Double,
51+
DoubleRange,
52+
Field,
53+
Float,
54+
FloatRange,
55+
GeoPoint,
56+
GeoShape,
57+
HalfFloat,
58+
Integer,
59+
IntegerRange,
60+
Ip,
61+
IpRange,
62+
Join,
63+
Keyword,
64+
Long,
65+
LongRange,
66+
Murmur3,
67+
Nested,
68+
Object,
69+
Percolator,
70+
Point,
71+
RangeField,
72+
RankFeature,
73+
RankFeatures,
74+
ScaledFloat,
75+
SearchAsYouType,
76+
Shape,
77+
Short,
78+
SparseVector,
79+
Text,
80+
TokenCount,
81+
construct_field,
82+
)
83+
from .function import SF
84+
from .index import (
85+
AsyncComposableIndexTemplate,
86+
AsyncIndex,
87+
AsyncIndexTemplate,
88+
ComposableIndexTemplate,
89+
Index,
90+
IndexTemplate,
91+
)
92+
from .mapping import AsyncMapping, Mapping
93+
from .query import Q, Query
94+
from .response import AggResponse, Response, UpdateByQueryResponse
95+
from .search import (
96+
AsyncEmptySearch,
97+
AsyncMultiSearch,
98+
AsyncSearch,
99+
EmptySearch,
100+
MultiSearch,
101+
Search,
102+
)
103+
from .update_by_query import AsyncUpdateByQuery, UpdateByQuery
104+
from .utils import AttrDict, AttrList, DslBase
105+
from .wrappers import Range
106+
107+
__all__ = [
108+
"A",
109+
"Agg",
110+
"AggResponse",
111+
"AsyncComposableIndexTemplate",
112+
"AsyncDocument",
113+
"AsyncEmptySearch",
114+
"AsyncFacetedSearch",
115+
"AsyncIndex",
116+
"AsyncIndexTemplate",
117+
"AsyncMapping",
118+
"AsyncMultiSearch",
119+
"AsyncSearch",
120+
"AsyncUpdateByQuery",
121+
"AttrDict",
122+
"AttrList",
123+
"Binary",
124+
"Boolean",
125+
"Byte",
126+
"Completion",
127+
"ComposableIndexTemplate",
128+
"ConstantKeyword",
129+
"CustomField",
130+
"Date",
131+
"DateHistogramFacet",
132+
"DateRange",
133+
"DenseVector",
134+
"Document",
135+
"Double",
136+
"DoubleRange",
137+
"DslBase",
138+
"ElasticsearchDslException",
139+
"EmptySearch",
140+
"Facet",
141+
"FacetedResponse",
142+
"FacetedSearch",
143+
"Field",
144+
"Float",
145+
"FloatRange",
146+
"GeoPoint",
147+
"GeoShape",
148+
"HalfFloat",
149+
"HistogramFacet",
150+
"IllegalOperation",
151+
"Index",
152+
"IndexTemplate",
153+
"InnerDoc",
154+
"Integer",
155+
"IntegerRange",
156+
"Ip",
157+
"IpRange",
158+
"Join",
159+
"Keyword",
160+
"Long",
161+
"LongRange",
162+
"M",
163+
"Mapping",
164+
"MetaField",
165+
"MultiSearch",
166+
"Murmur3",
167+
"Nested",
168+
"NestedFacet",
169+
"Object",
170+
"Percolator",
171+
"Point",
172+
"Q",
173+
"Query",
174+
"Range",
175+
"RangeFacet",
176+
"RangeField",
177+
"RankFeature",
178+
"RankFeatures",
179+
"Response",
180+
"SF",
181+
"ScaledFloat",
182+
"Search",
183+
"SearchAsYouType",
184+
"Shape",
185+
"Short",
186+
"SparseVector",
187+
"TermsFacet",
188+
"Text",
189+
"TokenCount",
190+
"UnknownDslObject",
191+
"UpdateByQuery",
192+
"UpdateByQueryResponse",
193+
"ValidationException",
194+
"analyzer",
195+
"async_connections",
196+
"char_filter",
197+
"connections",
198+
"construct_field",
199+
"mapped_field",
200+
"normalizer",
201+
"token_filter",
202+
"tokenizer",
203+
]

‎elasticsearch/dsl/_async/__init__.py

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# Licensed to Elasticsearch B.V. under one or more contributor
2+
# license agreements. See the NOTICE file distributed with
3+
# this work for additional information regarding copyright
4+
# ownership. Elasticsearch B.V. licenses this file to you under
5+
# the Apache License, Version 2.0 (the "License"); you may
6+
# not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing,
12+
# software distributed under the License is distributed on an
13+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
# KIND, either express or implied. See the License for the
15+
# specific language governing permissions and limitations
16+
# under the License.

0 commit comments

Comments
 (0)