django-es / django-elasticsearch-dsl

This is a package that allows indexing of django models in elasticsearch with elasticsearch-dsl-py.
Other
1.03k stars 264 forks source link

Supporting ASGi #286

Open Andrew-Chen-Wang opened 4 years ago

Andrew-Chen-Wang commented 4 years ago

Hi! Thanks for keeping this package alive!

I'm pushing for a lot of async features for Django, and I happened to need web sockets for autocomplete. The Elasticsearch-py documentation specifies that https://elasticsearch-py.readthedocs.io/en/master/async.html#elasticsearch.AsyncElasticsearch we'd need some kind of Connection class but I can't seem to find that for this.

How would I implement this? Thanks!

safwanrahman commented 4 years ago

I do not know how it is possible. Seems like async connection is new in elasticsearch-py. need to wait untill elasticsearch-dsl supports it.

Andrew-Chen-Wang commented 4 years ago

https://github.com/elastic/elasticsearch-py/blob/ff73292cc6605579ee93df190322feab274d01fd/elasticsearch/__init__.py#L32

How is the client usually set for Elasticsearch? Is it even set in this repository? It should just be the same way for async.

safwanrahman commented 4 years ago

@Andrew-Chen-Wang You can set the client while search I think by passing the client manually to elasticsearch-dsl

Andrew-Chen-Wang commented 4 years ago

Ah I see. So for the Django settings, like this: ELASTICSEARCH_DSL = {"default": {"hosts": "localhost:9200"}} is only meant for passing the args to the Elasticsearch client?

sethmlarson commented 4 years ago

BTW: There is no native async support in Elasticsearch-DSL but it's on my priority list.

safwanrahman commented 4 years ago

@Andrew-Chen-Wang Seems like it is not supported by elasticsearch-dsl still! I would suggest you to wait untill it get upstream support.

BTW, Thanks @sethmlarson for keeping eye on this project! 😃😁

Andrew-Chen-Wang commented 4 years ago

I see, thank you!

belegnar commented 4 years ago

They did it https://github.com/elastic/elasticsearch-py/blob/2b450ebb69b3a2207c902baf49ba1a3414cf5566/elasticsearch/_async/client/__init__.pyi#L58

Andrew-Chen-Wang commented 4 years ago

@belegnar Seems to just be the low level client. I think this package uses DSL version which doesn't seem to support async yet.