-
Notifications
You must be signed in to change notification settings - Fork 25.8k
fix: Correctly pickup MRT value for msearch's search requests
#138583
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: Correctly pickup MRT value for msearch's search requests
#138583
Conversation
|
Will mark it as ready once the CI issue is resolved. |
|
Pinging @elastic/es-search-foundations (Team:Search Foundations) |
|
Hi @pawankartik-elastic, I've created a changelog YAML for you. |
| public void testMrtValuesArePickedCorrectly() throws IOException { | ||
|
|
||
| { | ||
| // If no MRT is specified, all searches should default to true. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why does it default to true?
Is that because _msearch always uses _search rather than _async_search and _search defaults to true?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right. And when the SearchRequest object is instantiated, MRT defaults to true.
quux00
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
💔 Backport failed
You can use sqren/backport to manually backport by running |
…tic#138583) Do not override MRT from the request's body with the query param value. (cherry picked from commit 3d0a647) # Conflicts: # server/src/main/java/org/elasticsearch/rest/action/search/RestMultiSearchAction.java
💚 All backports created successfully
Questions ?Please refer to the Backport tool documentation |
…tic#138583) Do not override MRT from the request's body with the query param value. (cherry picked from commit 3d0a647) # Conflicts: # server/src/main/java/org/elasticsearch/rest/action/search/RestMultiSearchAction.java
…tic#138583) Do not override MRT from the request's body with the query param value. (cherry picked from commit 3d0a647) # Conflicts: # server/src/main/java/org/elasticsearch/rest/action/search/RestMultiSearchAction.java
#138583) (#139586) * fix: Correctly pickup MRT value for `msearch`'s search requests (#138583) Do not override MRT from the request's body with the query param value. (cherry picked from commit 3d0a647) # Conflicts: # server/src/main/java/org/elasticsearch/rest/action/search/RestMultiSearchAction.java * Fix CI
Here's the before code:
parseMultiLineRequest()is responsible for parsing themsearch's body. Within this method, we instantiate a newSearchRequestobject for each request and set its MRT to whatever's mentioned in the query parameter (the default fallback value istrue). Then, the body of each request is read byreadMultiLineFormat(), which extracts the MRT value in the request's body (if present) and sets it by overwriting the previously set value. This way, the MRT value in the request body takes precedence over the query parameter.However, when the parsing and reading are done, we end up setting the query param value again before adding the request to the
msearchobject (ref above code and the code comment). Whatever value we read from the request's body is now lost; effectively, we're ignoring whatever value is present in the request's body.The fix is to drop the problematic MRT setting op after the request's parsing is complete.