Skip to content

fix application crushes with error in AsyncSearch().count() method #2

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

Open
wants to merge 4 commits into
base: async-io
Choose a base branch
from

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