This issue occurred when using flask library.
Consider the below example:
First time when get_data is invoked via API, it worked fine, return the data. On successive attempts it started failing.
from flask import Flask
from elasticsearch import AsyncElasticsearch
es = AsyncElasticsearch([
{'host': 'localhost'}
])
async def get_data(self, index, page_from=0, page_size=5):
body = {"query": {"match_all": {}}}
return await self.es.search(
index=index,
body=body,
from_=page_from,
size=page_size
)
Instead of using from flask import Flask I tried with aioFlask from aioflask import Flask and it worked fine.
Happy to take your suggestion as well.
Also, would like to know if async elasticsearch is compatible with flask 2.x as of now.
Apache, Apache Lucene, Apache Hadoop, Hadoop, HDFS and the yellow elephant
logo are trademarks of the
Apache Software Foundation
in the United States and/or other countries.