Open realsuayip opened 2 months ago
Yes. Typing isn't complete in the current release. We are working on typing all the Elasticsearch structures including queries and responses, but that will come in a later release.
The same thing happens for response.hits.hits
.
Will accessing .hits.hits
still be supported in the future, or should we use .hits
instead?
If you use .hits.hits
you are accessing the raw response from Elasticsearch. When you use .hits
you are accessing the results after being processed by this library, which in my opinion is preferable. The way this is implemented right now is confusing, but my hope is that .hits.hits
will give you access to the unmodified response (possibly with missing or generic typing) and .hits
will provide access with correct typing.
Since the returned type is actually
AttrList
rather than plain list, accessing those attributes will result in type errors.https://github.com/elastic/elasticsearch-dsl-py/blob/318ea9a9e4b792325556671e1537df9032ee4e65/elasticsearch_dsl/response/__init__.py#L93
e.g.,
error: "List[Hit]" has no attribute "total" [attr-defined]