-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Inconsistent behavior with body and index parameter order in the search method #2706
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
Comments
Hello, and thank you for your clear report. I find the claim that the behavior changes based on the order of parameters really surprising. The point of forcing our users to use keyword arguments since elasticsearch-py 8.0 is to avoid this class of errors entirely. The client code itself does not care about the order, we let the Python interpreter handle it for us. Here's how elasticsearch-py/elasticsearch/_sync/client/__init__.py Lines 3752 to 3848 in e67fed8
|
I'm going to go ahead and close this, but I would still be happy to know if you fixed your problem or not. And I can always reopen if needed. |
When using the search method in the Elasticsearch client library, I encountered an unexpected behavior where the order of the body, index, and size parameters affects the function's operation. Here are the details:
Working code (as expected):
In this case, with index first, followed by body and size, the search works as expected.
Code that throws an error:
When the order of parameters is reversed, placing body before index, the search fails:
Here, the search does not work, and the only relevant difference between these cases is the parameter order.
Code where the reversed order does not cause an error:
Even with body and index reversed, the search works when size is not used:
response = es.search(body=body, index=index)
Summary of unexpected behavior: This inconsistency appears specifically when adding the size parameter (elasticsearch version 8.15.0) while reversing the order of body and index. The expected behavior is for the search method to work regardless of parameter order as long as all provided parameters are valid.
The text was updated successfully, but these errors were encountered: