Skip to content

Commit 561b50c

Browse files
minor fixes
1 parent d6a09fd commit 561b50c

3 files changed

Lines changed: 28 additions & 8 deletions

File tree

docs/reference/dsl_how_to_guides.md

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1247,7 +1247,7 @@ class Post(AsyncDocument):
12471247

12481248
#### Data types [_data_types]
12491249

1250-
The `Document` instances can use native python types such as `str` and `datetime` for its attributes. In case of `Object` or `Nested` fields an instance of the `InnerDoc` subclass is used, as in the `add_comment` method in the above example, where we are creating an instance of the `Comment` class.
1250+
The `Document` instances can use native Python types such as `str` and `datetime` for its attributes. In case of `Object` or `Nested` fields an instance of the `InnerDoc` subclass is used, as in the `add_comment` method in the above example, where we are creating an instance of the `Comment` class.
12511251

12521252
There are also specific type classes that were created to make working with some field types easier, for example the `Range` object used in any of the [range fields](elasticsearch://reference/elasticsearch/mapping-reference/range.md):
12531253

@@ -1664,12 +1664,14 @@ class Post(AsyncDocument):
16641664

16651665
::::
16661666

1667-
In that case any `datetime` object passed in (or parsed from elasticsearch) will be treated as if it were in `UTC` timezone.
1667+
In that case any `datetime` object passed in (or parsed from Elasticsearch) will be treated as if it were in `UTC` timezone.
16681668

16691669

16701670
#### Custom field names
16711671

1672-
By default, the `Document` and `AsyncDocument` classes use the names given to the field attributes as the field names in the Elasticsearch index. There cases, however, where it is necessary for the names of a field in Python and Elasticsearch to be different.
1672+
By default, the `Document` and `AsyncDocument` classes use the names given to the field attributes as the field names in the Elasticsearch index. But sometimes it is necessary for the names of a field in Python and Elasticsearch to be different, such as when the Elasticsearch name is not a valid Python identifier.
1673+
1674+
The following example shows how to define the Elasticsearch field `@timestamp`, used with data streams:
16731675

16741676
:::{tab-item} Standard Python
16751677
:sync: sync
@@ -1709,6 +1711,8 @@ class MyDoc(AsyncDocument):
17091711

17101712
::::
17111713

1714+
The conversion between the Python and Elasticsearch names happens automatically during serialization and deserialization of `Document` and `AsyncDocument` instances. The Elasticsearch field names must be used when sending requests outside of the document classes. Likewise, responses from Elasticsearch that are not deserialized to a document class will reference the Elasticsearch field names.
1715+
17121716
#### Document life cycle [life-cycle]
17131717

17141718
Before you first use the `Post` document type, you need to create the mappings in Elasticsearch. For that you can either use the `index` object or create the mappings directly by calling the `init` class method:
@@ -2589,7 +2593,7 @@ dev_blogs.setting(number_of_shards=1)
25892593
The DSL module also exposes an option to manage [index templates](docs-content://manage-data/data-store/templates.md) in elasticsearch using the `ComposableIndexTemplate` and `IndexTemplate` classes, which have a similar API to `Index`.
25902594

25912595
::::{note}
2592-
Composable index templates should always be preferred over the legacy index templates, which are deprecated.
2596+
Composable index templates should always be preferred over the legacy index templates.
25932597

25942598
::::
25952599

elasticsearch/dsl/types.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6183,9 +6183,12 @@ class PhraseSuggestOption(AttrDict[Any]):
61836183
class Profile(AttrDict[Any]):
61846184
"""
61856185
:arg shards: (required)
6186+
:arg request: When profiling is enabled, the original query source and
6187+
target indices from the coordinating request.
61866188
"""
61876189

61886190
shards: Sequence["ShardProfile"]
6191+
request: "SearchRequestCoordinatorMetadata"
61896192

61906193

61916194
class QueryBreakdown(AttrDict[Any]):
@@ -6398,6 +6401,23 @@ class SearchProfile(AttrDict[Any]):
63986401
rewrite_time: int
63996402

64006403

6404+
class SearchRequestCoordinatorMetadata(AttrDict[Any]):
6405+
"""
6406+
Coordinator snapshot of the original search request, serialized under
6407+
`profile.request` when profiling is enabled. Introduced in
6408+
Elasticsearch 9.5; omitted when the cluster contains mixed-version
6409+
nodes that do not serialize this metadata.
6410+
6411+
:arg source: Original query source from the search request
6412+
(`SearchSourceBuilder` as JSON).
6413+
:arg indices: Target index expressions from the request (before index
6414+
resolution).
6415+
"""
6416+
6417+
source: Dict[str, Any]
6418+
indices: Sequence[str]
6419+
6420+
64016421
class ShardFailure(AttrDict[Any]):
64026422
"""
64036423
:arg reason: (required)

elasticsearch/dsl/utils.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -342,13 +342,9 @@ def __init__(self, _expand__to_dot: Optional[bool] = None, **params: Any) -> Non
342342
if _expand__to_dot is None:
343343
_expand__to_dot = EXPAND__TO_DOT
344344
self._params: Dict[str, Any] = {}
345-
self._es_named: Optional[str] = None
346345
for pname, pvalue in params.items():
347346
if pvalue is DEFAULT:
348347
continue
349-
if pname == "_es_name":
350-
self._es_named = pvalue
351-
continue
352348
# expand "__" to dots
353349
if "__" in pname and _expand__to_dot:
354350
pname = pname.replace("__", ".")

0 commit comments

Comments
 (0)