llama_index icon indicating copy to clipboard operation
llama_index copied to clipboard

[Bug]: About ServerDisconnectedError(Server disconnected) in ElasticsearchStore

Open Hspix opened this issue 11 months ago • 3 comments

Bug Description

When there are more than 10 queries running simultaneously, the AsyncElasticsearch client may raise a ServerDisconnectedError(Server disconnected) exception, as shown below:

elastic_transport.ConnectionError: Connection error caused by: ConnectionError(Connection error caused by: ServerDisconnectedError(Server disconnected))

Version

llama-index=0.10.14 llama-index-vector-stores-elasticsearch=0.1.5

Steps to Reproduce

A potential issue with the aquery method in the llama_index.vector_stores.elasticsearch.base module could be the cause of this problem, as shown below:

        async with self.client as client:
            response = await client.search(
                index=self.index_name,
                **es_query,
                size=query.similarity_top_k,
                _source={"excludes": [self.vector_field]},
            )

I tried running the code block independently with manual queries, but it still generated the same exception.

However, nothing happens when using the async client directly without async with:

            response = await self.client.search(
                index=self.index_name,
                **es_query,
                size=query.similarity_top_k,
                _source={"excludes": [self.vector_field]},
            )

So, I guess that async with is redundant?

Relevant Logs/Tracbacks

No response

Hspix avatar Mar 05 '24 09:03 Hspix