Skip to content

Commit cff6ec6

Browse files
[Backport 8.x] remove DSL code and redirect imports to unified Python client (#1972)
* remove DSL code and redirect imports to unified Python client (#1968) * remove DSL code and redirect imports to unified Python client * add note about merge in README * install main branch from client until 9.0 is released * make version reporting backwards compatible * add missing readthedocs configuration for sphinx * fix readme note formatting * linter fix * deprecation notice in the docs (cherry picked from commit 9e52595) * Fix 9.0 documentation link * Use 8.x client for tests --------- Co-authored-by: Miguel Grinberg <miguel.grinberg@gmail.com>
1 parent 6aaba44 commit cff6ec6

Some content is hidden

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

49 files changed

+61
-21371
lines changed

.readthedocs.yaml

+1
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,5 @@ python:
1313
- develop
1414

1515
sphinx:
16+
configuration: docs/conf.py
1617
fail_on_warning: true

README

+22
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,28 @@
11
Elasticsearch DSL
22
=================
33

4+
Deprecation notice
5+
------------------
6+
7+
As of release 8.18.0, the Elasticsearch DSL package is part of the official
8+
`Elasticsearch Python client <https://github.com/elastic/elasticsearch-py>`_,
9+
so a separate install is not needed anymore. To migrate, follow these steps:
10+
11+
- Uninstall the ``elasticsearch-dsl`` package
12+
- Make sure you have version 8.18.0 or newer of the ``elasticsearch`` package
13+
installed
14+
- Replace ``elasticsearch_dsl`` with ``elasticsearch.dsl`` in your imports
15+
16+
To prevent applications from breaking unexpectedly due to this change, the
17+
8.18.0 release of this package automatically redirects all imports to the
18+
corresponding modules of the Python client package.
19+
20+
The following instructions only apply to versions 8.17 and older of this
21+
package.
22+
23+
Introduction
24+
------------
25+
426
Elasticsearch DSL is a high-level library whose aim is to help with writing and
527
running queries against Elasticsearch. It is built on top of the official
628
low-level client (`elasticsearch-py <https://github.com/elastic/elasticsearch-py>`_).

docs/index.rst

+21
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,27 @@
11
Elasticsearch DSL
22
=================
33

4+
.. note::
5+
6+
As of release 8.18.0, the Elasticsearch DSL package is part of the official
7+
`Elasticsearch Python client <https://github.com/elastic/elasticsearch-py>`_,
8+
so a separate install is not needed anymore. To migrate, follow these steps:
9+
10+
- Uninstall the ``elasticsearch-dsl`` package
11+
- Make sure you have version 8.18.0 or newer of the ``elasticsearch`` package
12+
installed
13+
- Replace ``elasticsearch_dsl`` with ``elasticsearch.dsl`` in your imports
14+
15+
To prevent applications from breaking unexpectedly due to this change, the
16+
8.18.0 release of the ``elasticsearch-dsl`` package automatically redirects
17+
all imports to the corresponding modules of the Python client package.
18+
19+
This documentation site applies to releases before 8.18.0. For newer releases
20+
use the following links:
21+
22+
- `8.x releases starting with 8.18.0 <https://www.elastic.co/guide/en/elasticsearch/client/python-api/8.18/elasticsearch-dsl.html>`_
23+
- `9.x releases <https://www.elastic.co/docs/reference/elasticsearch/clients/python/elasticsearch-dsl>`_
24+
425
Elasticsearch DSL is a high-level library whose aim is to help with writing and
526
running queries against Elasticsearch. It is built on top of the official
627
low-level client (`elasticsearch-py <https://github.com/elastic/elasticsearch-py>`_).

elasticsearch_dsl/__init__.py

+10-188
Original file line numberDiff line numberDiff line change
@@ -15,192 +15,14 @@
1515
# specific language governing permissions and limitations
1616
# under the License.
1717

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
18+
import sys
10619

107-
VERSION = (8, 17, 1)
108-
__version__ = VERSION
109-
__versionstr__ = ".".join(map(str, VERSION))
110-
__all__ = [
111-
"A",
112-
"Agg",
113-
"AggResponse",
114-
"AsyncComposableIndexTemplate",
115-
"AsyncDocument",
116-
"AsyncEmptySearch",
117-
"AsyncFacetedSearch",
118-
"AsyncIndex",
119-
"AsyncIndexTemplate",
120-
"AsyncMapping",
121-
"AsyncMultiSearch",
122-
"AsyncSearch",
123-
"AsyncUpdateByQuery",
124-
"AttrDict",
125-
"AttrList",
126-
"Binary",
127-
"Boolean",
128-
"Byte",
129-
"Completion",
130-
"ComposableIndexTemplate",
131-
"ConstantKeyword",
132-
"CustomField",
133-
"Date",
134-
"DateHistogramFacet",
135-
"DateRange",
136-
"DenseVector",
137-
"Document",
138-
"Double",
139-
"DoubleRange",
140-
"DslBase",
141-
"ElasticsearchDslException",
142-
"EmptySearch",
143-
"Facet",
144-
"FacetedResponse",
145-
"FacetedSearch",
146-
"Field",
147-
"Float",
148-
"FloatRange",
149-
"GeoPoint",
150-
"GeoShape",
151-
"HalfFloat",
152-
"HistogramFacet",
153-
"IllegalOperation",
154-
"Index",
155-
"IndexTemplate",
156-
"InnerDoc",
157-
"Integer",
158-
"IntegerRange",
159-
"Ip",
160-
"IpRange",
161-
"Join",
162-
"Keyword",
163-
"Long",
164-
"LongRange",
165-
"M",
166-
"Mapping",
167-
"MetaField",
168-
"MultiSearch",
169-
"Murmur3",
170-
"Nested",
171-
"NestedFacet",
172-
"Object",
173-
"Percolator",
174-
"Point",
175-
"Q",
176-
"Query",
177-
"Range",
178-
"RangeFacet",
179-
"RangeField",
180-
"RankFeature",
181-
"RankFeatures",
182-
"Response",
183-
"SF",
184-
"ScaledFloat",
185-
"Search",
186-
"SearchAsYouType",
187-
"Shape",
188-
"Short",
189-
"SparseVector",
190-
"TermsFacet",
191-
"Text",
192-
"TokenCount",
193-
"UnknownDslObject",
194-
"UpdateByQuery",
195-
"UpdateByQueryResponse",
196-
"ValidationException",
197-
"analyzer",
198-
"async_connections",
199-
"char_filter",
200-
"connections",
201-
"construct_field",
202-
"mapped_field",
203-
"normalizer",
204-
"token_filter",
205-
"tokenizer",
206-
]
20+
from elasticsearch import __version__, dsl # noqa: F401
21+
22+
modules = [mod for mod in sys.modules.keys() if mod.startswith("elasticsearch.dsl")]
23+
for mod in modules:
24+
sys.modules[mod.replace("elasticsearch.dsl", "elasticsearch_dsl")] = sys.modules[
25+
mod
26+
]
27+
sys.modules["elasticsearch_dsl"].VERSION = __version__
28+
sys.modules["elasticsearch_dsl"].__versionstr__ = ".".join(map(str, __version__))

elasticsearch_dsl/_async/__init__.py

-16
This file was deleted.

0 commit comments

Comments
 (0)