Skip to content
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

Add Elasticsearch-DSL code #2736

Merged
merged 11 commits into from
Jan 17, 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
4 changes: 2 additions & 2 deletions elasticsearch/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,15 @@
from ._version import __versionstr__

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

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

Expand Down
2 changes: 1 addition & 1 deletion elasticsearch/_async/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ async def map_actions() -> AsyncIterable[_TYPE_BULK_ACTION_HEADER_AND_BODY]:
]
ok: bool
info: Dict[str, Any]
async for data, (ok, info) in azip( # type: ignore
async for data, (ok, info) in azip( # type: ignore[assignment, misc]
bulk_data,
_process_bulk_chunk(
client,
Expand Down
2 changes: 1 addition & 1 deletion elasticsearch/_sync/client/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ def host_mapping_to_node_config(host: Mapping[str, Union[str, int]]) -> NodeConf
)
options["path_prefix"] = options.pop("url_prefix")

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


def cloud_id_to_node_configs(cloud_id: str) -> List[NodeConfig]:
Expand Down
203 changes: 203 additions & 0 deletions elasticsearch/dsl/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,203 @@
# Licensed to Elasticsearch B.V. under one or more contributor
# license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright
# ownership. Elasticsearch B.V. licenses this file to you under
# the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# 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

__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",
]
16 changes: 16 additions & 0 deletions elasticsearch/dsl/_async/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Licensed to Elasticsearch B.V. under one or more contributor
# license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright
# ownership. Elasticsearch B.V. licenses this file to you under
# the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
Loading
Loading