Skip to content

[Backport 8.x] remove DSL code and redirect imports to unified Python client #1972

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Apr 16, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .readthedocs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,5 @@ python:
- develop

sphinx:
configuration: docs/conf.py
fail_on_warning: true
22 changes: 22 additions & 0 deletions README
Original file line number Diff line number Diff line change
@@ -1,6 +1,28 @@
Elasticsearch DSL
=================

Deprecation notice
------------------

As of release 8.18.0, the Elasticsearch DSL package is part of the official
`Elasticsearch Python client <https://github.com/elastic/elasticsearch-py>`_,
so a separate install is not needed anymore. To migrate, follow these steps:

- Uninstall the ``elasticsearch-dsl`` package
- Make sure you have version 8.18.0 or newer of the ``elasticsearch`` package
installed
- Replace ``elasticsearch_dsl`` with ``elasticsearch.dsl`` in your imports

To prevent applications from breaking unexpectedly due to this change, the
8.18.0 release of this package automatically redirects all imports to the
corresponding modules of the Python client package.

The following instructions only apply to versions 8.17 and older of this
package.

Introduction
------------

Elasticsearch DSL is a high-level library whose aim is to help with writing and
running queries against Elasticsearch. It is built on top of the official
low-level client (`elasticsearch-py <https://github.com/elastic/elasticsearch-py>`_).
Expand Down
21 changes: 21 additions & 0 deletions docs/index.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,27 @@
Elasticsearch DSL
=================

.. note::

As of release 8.18.0, the Elasticsearch DSL package is part of the official
`Elasticsearch Python client <https://github.com/elastic/elasticsearch-py>`_,
so a separate install is not needed anymore. To migrate, follow these steps:

- Uninstall the ``elasticsearch-dsl`` package
- Make sure you have version 8.18.0 or newer of the ``elasticsearch`` package
installed
- Replace ``elasticsearch_dsl`` with ``elasticsearch.dsl`` in your imports

To prevent applications from breaking unexpectedly due to this change, the
8.18.0 release of the ``elasticsearch-dsl`` package automatically redirects
all imports to the corresponding modules of the Python client package.

This documentation site applies to releases before 8.18.0. For newer releases
use the following links:

- `8.x releases starting with 8.18.0 <https://www.elastic.co/guide/en/elasticsearch/client/python-api/8.18/elasticsearch-dsl.html>`_
- `9.x releases <https://www.elastic.co/docs/reference/elasticsearch/clients/python/elasticsearch-dsl>`_

Elasticsearch DSL is a high-level library whose aim is to help with writing and
running queries against Elasticsearch. It is built on top of the official
low-level client (`elasticsearch-py <https://github.com/elastic/elasticsearch-py>`_).
Expand Down
198 changes: 10 additions & 188 deletions elasticsearch_dsl/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,192 +15,14 @@
# specific language governing permissions and limitations
# under the License.

from . import async_connections, connections
from .aggs import A, Agg
from .analysis import analyzer, char_filter, normalizer, token_filter, tokenizer
from .document import AsyncDocument, Document
from .document_base import InnerDoc, M, MetaField, mapped_field
from .exceptions import (
ElasticsearchDslException,
IllegalOperation,
UnknownDslObject,
ValidationException,
)
from .faceted_search import (
AsyncFacetedSearch,
DateHistogramFacet,
Facet,
FacetedResponse,
FacetedSearch,
HistogramFacet,
NestedFacet,
RangeFacet,
TermsFacet,
)
from .field import (
Binary,
Boolean,
Byte,
Completion,
ConstantKeyword,
CustomField,
Date,
DateRange,
DenseVector,
Double,
DoubleRange,
Field,
Float,
FloatRange,
GeoPoint,
GeoShape,
HalfFloat,
Integer,
IntegerRange,
Ip,
IpRange,
Join,
Keyword,
Long,
LongRange,
Murmur3,
Nested,
Object,
Percolator,
Point,
RangeField,
RankFeature,
RankFeatures,
ScaledFloat,
SearchAsYouType,
Shape,
Short,
SparseVector,
Text,
TokenCount,
construct_field,
)
from .function import SF
from .index import (
AsyncComposableIndexTemplate,
AsyncIndex,
AsyncIndexTemplate,
ComposableIndexTemplate,
Index,
IndexTemplate,
)
from .mapping import AsyncMapping, Mapping
from .query import Q, Query
from .response import AggResponse, Response, UpdateByQueryResponse
from .search import (
AsyncEmptySearch,
AsyncMultiSearch,
AsyncSearch,
EmptySearch,
MultiSearch,
Search,
)
from .update_by_query import AsyncUpdateByQuery, UpdateByQuery
from .utils import AttrDict, AttrList, DslBase
from .wrappers import Range
import sys

VERSION = (8, 17, 1)
__version__ = VERSION
__versionstr__ = ".".join(map(str, VERSION))
__all__ = [
"A",
"Agg",
"AggResponse",
"AsyncComposableIndexTemplate",
"AsyncDocument",
"AsyncEmptySearch",
"AsyncFacetedSearch",
"AsyncIndex",
"AsyncIndexTemplate",
"AsyncMapping",
"AsyncMultiSearch",
"AsyncSearch",
"AsyncUpdateByQuery",
"AttrDict",
"AttrList",
"Binary",
"Boolean",
"Byte",
"Completion",
"ComposableIndexTemplate",
"ConstantKeyword",
"CustomField",
"Date",
"DateHistogramFacet",
"DateRange",
"DenseVector",
"Document",
"Double",
"DoubleRange",
"DslBase",
"ElasticsearchDslException",
"EmptySearch",
"Facet",
"FacetedResponse",
"FacetedSearch",
"Field",
"Float",
"FloatRange",
"GeoPoint",
"GeoShape",
"HalfFloat",
"HistogramFacet",
"IllegalOperation",
"Index",
"IndexTemplate",
"InnerDoc",
"Integer",
"IntegerRange",
"Ip",
"IpRange",
"Join",
"Keyword",
"Long",
"LongRange",
"M",
"Mapping",
"MetaField",
"MultiSearch",
"Murmur3",
"Nested",
"NestedFacet",
"Object",
"Percolator",
"Point",
"Q",
"Query",
"Range",
"RangeFacet",
"RangeField",
"RankFeature",
"RankFeatures",
"Response",
"SF",
"ScaledFloat",
"Search",
"SearchAsYouType",
"Shape",
"Short",
"SparseVector",
"TermsFacet",
"Text",
"TokenCount",
"UnknownDslObject",
"UpdateByQuery",
"UpdateByQueryResponse",
"ValidationException",
"analyzer",
"async_connections",
"char_filter",
"connections",
"construct_field",
"mapped_field",
"normalizer",
"token_filter",
"tokenizer",
]
from elasticsearch import __version__, dsl # noqa: F401

modules = [mod for mod in sys.modules.keys() if mod.startswith("elasticsearch.dsl")]
for mod in modules:
sys.modules[mod.replace("elasticsearch.dsl", "elasticsearch_dsl")] = sys.modules[
mod
]
sys.modules["elasticsearch_dsl"].VERSION = __version__
sys.modules["elasticsearch_dsl"].__versionstr__ = ".".join(map(str, __version__))
16 changes: 0 additions & 16 deletions elasticsearch_dsl/_async/__init__.py

This file was deleted.

Loading