Skip to content

Python Module - es.indices.exists doesn't support wildcards as it should #2708

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

Closed
mbeaufre opened this issue Nov 13, 2024 · 5 comments
Closed

Comments

@mbeaufre
Copy link

mbeaufre commented Nov 13, 2024

In the documentation:
Documentation of exists function

It is written that exists method supports wildcards ('*'). My screenshot aim to prove that it doesn't, in version 8.14 and lilkely later versions, since it was already written in the documentation for release 8.14.0 it had the support for wildcards.

Image

Just for the context: This index doesn't exists, neither does a variation of its name.

@pquentin
Copy link
Member

Hello! Thank you for your question. In the future, I would prefer Markdown code blocks rather than screenshots of code, as they are easier to work with, even when working in a notebook.

If I understand correctly, what you're seeing is:

  • es.indices.exist(index="...-data-2024-11-12") returns False
  • es.indices.exist(index="...-data-2024-11-12*") returns True
  • es.indices.exist(index="...-data-2024-11-1*") returns True

If yes, then that's not evidence of the wildcard support failing. I believe you don't have an index named ...-data-2024-11-12 (which is why the first call returns False), but you probably have an index named like ...-data-2024-11-12-001, which is why the two other calls return True.

To confirm that theory you can use es.indices.get(index="...-data-2024-11-12*") (docs) and you will see which indices match.

@pquentin
Copy link
Member

I just saw your edit, and can confirm the behavior. Looking into it more, thank you.

@pquentin
Copy link
Member

pquentin commented Nov 13, 2024

Digging into it a bit more, I realized that you need to use allow_no_indices=False to get the behavior you want. The default behavior is definitely confusing, but was kept this way to not break backward compatibility and be consistent with the Get Index API that also returns 200 OK when no indices match with a wildcard.

es.indices.exists(index="...-data-2024-11-12*", allow_no_indices=False)

@pquentin
Copy link
Member

I'm going to go ahead and close this, but I would still be happy to know if that fixed your problem or not. And I can always reopen if needed.

@mbeaufre
Copy link
Author

Hello !

Sorry about the non-markdown format, noted for the next time. Thanks for your help, it worked.

I read the doc of the exists function but didn't understand that allow_no_indices did what I wanted.

Merci !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants