Skip to content

Conversation

@jellex
Copy link

@jellex jellex commented Mar 23, 2021

I tried using AsyncSearh with next code:

from elasticsearch_dsl import AsyncSearch

search = AsyncSearch(using='my_connection_name', index='my_index_name')
search = search.filter('term', docType='my_docType_name')
result = search.count()

and I get the following error:

  <...>
  File "<..>/elasticsearch_dsl/_async/search.py", line 430, in count
    return await es.count(index=self._index, body=d, **self._params)["count"]
TypeError: 'coroutine' object is not subscriptable

before this bug fix, when calling AsyncSearch().count(), the application crashes with the error TypeError: 'coroutine' object is not subscriptable

jellex added 2 commits March 23, 2021 20:14
before this bug fix, when calling AsyncSearch().count(), the application crashes with the error "TypeError: 'coroutine' object is not subscriptable"
@Andrew-Chen-Wang
Copy link

You can just do return (await es.count(index=self._index, body=d, **self._params))["count"] to make it in one line.

Not needed divide by a float to preserve milliseconds on the datetime, because 'data' already in the required format.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants