Skip to content
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

[FIX] elasticsearch vector_store: add await for self.client.indices.exist #11438

Merged
merged 1 commit into from
Feb 27, 2024

Conversation

nerdai
Copy link
Contributor

@nerdai nerdai commented Feb 27, 2024

Description

  • Since client is AsyncElasticsearchClient we need to have await on self.client.indices.exist otherwise it returns a Coroutine object

Fixes #11417

Type of Change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)

How Has This Been Tested?

Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration

  • Ran the script provided by the issue author and it works
  • I stared at the code and made sure it makes sense

@dosubot dosubot bot added the size:XS This PR changes 0-9 lines, ignoring generated files. label Feb 27, 2024
@@ -239,7 +239,7 @@ async def _create_index_if_not_exists(
index_name: Name of the AsyncElasticsearch index to create.
dims_length: Length of the embedding vectors.
"""
if self.client.indices.exists(index=index_name):
if await self.client.indices.exists(index=index_name):
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@logan-markewich IIRC I think there was some reason as to why we removed the await? Or maybe I'm wrong and it never was there to begin with.

I do think we need to have this since the client is and async client though.

Copy link
Contributor Author

@nerdai nerdai Feb 27, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

for visibility on this issue:

  • it appears a lower version of elasticsearch python client actually does not yield a Coroutine when clinet.indices.exists was invoked (see this older issue) -- there elasticsearch v8.8.0 was used.
  • this is no longer the case for the most recent version of elasticsearch (at time of this comment, v8.12.1).
  • since v8.12.1 is the minimum requirement for this integration (i.e. see pyproject.toml), we should be safe to add back await now.

@dosubot dosubot bot added the lgtm This PR has been approved by a maintainer label Feb 27, 2024
@nerdai nerdai merged commit bf2c8a4 into main Feb 27, 2024
8 checks passed
@nerdai nerdai deleted the nerdai/fix-elasticsearch-client branch February 27, 2024 17:11
Dominastorm pushed a commit to uptrain-ai/llama_index that referenced this pull request Feb 28, 2024
anoopshrma pushed a commit to anoopshrma/llama_index that referenced this pull request Mar 2, 2024
Izukimat pushed a commit to Izukimat/llama_index that referenced this pull request Mar 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
lgtm This PR has been approved by a maintainer size:XS This PR changes 0-9 lines, ignoring generated files.
Projects
None yet
2 participants