Skip to content

Commit 404e21e

Browse files
Add most recently added fields as top-level exports (#3078) (#3083)
* Add most recently added fields as top-level exports * add unit test to ensure all fields are exported (cherry picked from commit 9c61068) Co-authored-by: Miguel Grinberg <[email protected]>
1 parent d281593 commit 404e21e

File tree

2 files changed

+45
-0
lines changed

2 files changed

+45
-0
lines changed

elasticsearch/dsl/__init__.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,23 +38,30 @@
3838
TermsFacet,
3939
)
4040
from .field import (
41+
AggregateMetricDouble,
42+
Alias,
4143
Binary,
4244
Boolean,
4345
Byte,
4446
Completion,
4547
ConstantKeyword,
48+
CountedKeyword,
4649
CustomField,
4750
Date,
51+
DateNanos,
4852
DateRange,
4953
DenseVector,
5054
Double,
5155
DoubleRange,
5256
Field,
57+
Flattened,
5358
Float,
5459
FloatRange,
5560
GeoPoint,
5661
GeoShape,
5762
HalfFloat,
63+
Histogram,
64+
IcuCollationKeyword,
5865
Integer,
5966
IntegerRange,
6067
Ip,
@@ -63,21 +70,28 @@
6370
Keyword,
6471
Long,
6572
LongRange,
73+
MatchOnlyText,
6674
Murmur3,
6775
Nested,
6876
Object,
77+
Passthrough,
6978
Percolator,
7079
Point,
7180
RangeField,
7281
RankFeature,
7382
RankFeatures,
83+
RankVectors,
7484
ScaledFloat,
7585
SearchAsYouType,
86+
SemanticText,
7687
Shape,
7788
Short,
7889
SparseVector,
7990
Text,
8091
TokenCount,
92+
UnsignedLong,
93+
Version,
94+
Wildcard,
8195
construct_field,
8296
)
8397
from .function import SF
@@ -108,6 +122,8 @@
108122
"A",
109123
"Agg",
110124
"AggResponse",
125+
"AggregateMetricDouble",
126+
"Alias",
111127
"AsyncComposableIndexTemplate",
112128
"AsyncDocument",
113129
"AsyncEmptySearch",
@@ -126,9 +142,11 @@
126142
"Completion",
127143
"ComposableIndexTemplate",
128144
"ConstantKeyword",
145+
"CountedKeyword",
129146
"CustomField",
130147
"Date",
131148
"DateHistogramFacet",
149+
"DateNanos",
132150
"DateRange",
133151
"DenseVector",
134152
"Document",
@@ -142,12 +160,15 @@
142160
"FacetedResponse",
143161
"FacetedSearch",
144162
"Field",
163+
"Flattened",
145164
"Float",
146165
"FloatRange",
147166
"GeoPoint",
148167
"GeoShape",
149168
"HalfFloat",
169+
"Histogram",
150170
"HistogramFacet",
171+
"IcuCollationKeyword",
151172
"IllegalOperation",
152173
"Index",
153174
"IndexTemplate",
@@ -162,12 +183,14 @@
162183
"LongRange",
163184
"M",
164185
"Mapping",
186+
"MatchOnlyText",
165187
"MetaField",
166188
"MultiSearch",
167189
"Murmur3",
168190
"Nested",
169191
"NestedFacet",
170192
"Object",
193+
"Passthrough",
171194
"Percolator",
172195
"Point",
173196
"Q",
@@ -177,21 +200,26 @@
177200
"RangeField",
178201
"RankFeature",
179202
"RankFeatures",
203+
"RankVectors",
180204
"Response",
181205
"SF",
182206
"ScaledFloat",
183207
"Search",
184208
"SearchAsYouType",
209+
"SemanticText",
185210
"Shape",
186211
"Short",
187212
"SparseVector",
188213
"TermsFacet",
189214
"Text",
190215
"TokenCount",
191216
"UnknownDslObject",
217+
"UnsignedLong",
192218
"UpdateByQuery",
193219
"UpdateByQueryResponse",
194220
"ValidationException",
221+
"Version",
222+
"Wildcard",
195223
"analyzer",
196224
"async_connections",
197225
"char_filter",

test_elasticsearch/test_dsl/test_field.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
import pytest
2424
from dateutil import tz
2525

26+
from elasticsearch import dsl
2627
from elasticsearch.dsl import InnerDoc, Range, ValidationException, field
2728

2829

@@ -232,3 +233,19 @@ class Inner(InnerDoc):
232233

233234
with pytest.raises(ValidationException):
234235
field.Object(doc_class=Inner, dynamic=False)
236+
237+
238+
def test_all_fields_exported() -> None:
239+
"""Make sure that all the generated field classes are exported at the top-level"""
240+
fields = [
241+
f
242+
for f in dir(field)
243+
if isinstance(getattr(field, f), type)
244+
and issubclass(getattr(field, f), field.Field)
245+
]
246+
all = dir(dsl)
247+
not_found = []
248+
for f in fields:
249+
if f not in all:
250+
not_found.append(f)
251+
assert not_found == []

0 commit comments

Comments
 (0)