-
Notifications
You must be signed in to change notification settings - Fork 25.2k
Refactor SearchRequest to be parsed on the coordinating node #13859
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
Conversation
…urceBuilder to SearchSourceBuilder
Lots of NOCOMMITS are in the code as lots of compile errors have been temporarily commented out
This commit removes all the opaque bytes for extra_source and template_source. Instead source and extra_source etc. are represented as SearchSourceBuilder which can in-place be modified and is updated with the content of the request parameters. Template Source is parsed and evaluated which in-turn replaces the actual source.
Not the neatest implementation in the world. Maybe we should consider changing the builders so it is a single builder for sort and a single builder for rescore instead of a list of builders for each?
…refactoring # Conflicts: # core/src/test/java/org/elasticsearch/search/functionscore/DecayFunctionScoreIT.java # core/src/test/java/org/elasticsearch/search/functionscore/FunctionScoreFieldValueIT.java # core/src/test/java/org/elasticsearch/search/functionscore/FunctionScoreIT.java # core/src/test/java/org/elasticsearch/search/rescore/QueryRescorerIT.java
private String[] types = Strings.EMPTY_ARRAY; | ||
|
||
private int terminateAfter = DEFAULT_TERMINATE_AFTER; | ||
private SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder(); |
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.
any chance this can be final?
@colings86 this LGTM but I wonder what happened to all the |
@@ -505,18 +361,15 @@ public void writeTo(StreamOutput out) throws IOException { | |||
out.writeBoolean(true); | |||
scroll.writeTo(out); | |||
} | |||
out.writeBytesReference(source); | |||
out.writeBytesReference(extraSource); | |||
if (source == null) { |
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.
can the source ever be null? I think it shouldn't be optional in readFrom and writeTo
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.
I got confused with the count request, I see that this can be null, but I still wonder if it should? When does it make sense for it to be null? If it wasn't we could drop a lot of null checks around that.
# Conflicts: # core/src/main/java/org/elasticsearch/search/SearchService.java
@@ -71,12 +59,8 @@ | |||
@Nullable | |||
private String preference; | |||
|
|||
private BytesReference templateSource; | |||
private Template template; | |||
private SearchSourceBuilder source; |
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.
seems like we can make it final now?
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.
oh no we can't, sorry!
} catch (IOException e) { | ||
sb.append("source[_failed_to_convert_], "); | ||
} | ||
if (context.request().source() != null) { |
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.
the null check can be dropped maybe?
we decided with @colings86 to make the source builder not nullable in the SearchRequest, but to do it after we merge this PR to master. I just did a final round and this LGTM |
This change refactors the SearchRequest so it is parsed on the coordinating node and then sent as a serialised object to the shards. The SearchSourceBuilder encompasses the state of the bpdy of the search request (know in the code as source) and is embedded in the SearchRequest. On the shard the SearchSourceBuilder is used to populate the SearchContext where we used to parse the source JSON.
A few things to note: