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

Use SearchRequest copy constructor in ExpandSearchPhase #36772

Merged

Conversation

javanna
Copy link
Member

@javanna javanna commented Dec 18, 2018

Using the copy constructor introduced with #36641 guarantees that whenever new fields are added to SearchRequest they are properly propagated to its copies. Copies created in ExpandSearchPhase were missing a couple of recently added fields.

@javanna javanna added >enhancement :Search/Search Search-related issues that do not fall into other categories v7.0.0 v6.7.0 labels Dec 18, 2018
@elasticmachine
Copy link
Collaborator

Pinging @elastic/es-search

Copy link
Member

@cbuescher cbuescher left a comment

Choose a reason for hiding this comment

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

Left one small comment around a maybe redundant line that could be removed, but other than that LGTM

@@ -91,7 +91,8 @@ public void run() throws IOException {
SearchSourceBuilder sourceBuilder = buildExpandSearchSourceBuilder(innerHitBuilder, innerCollapseBuilder)
.query(groupQuery)
.postFilter(searchRequest.source().postFilter());
SearchRequest groupRequest = buildExpandSearchRequest(searchRequest, sourceBuilder);
SearchRequest groupRequest = new SearchRequest(searchRequest);
groupRequest.source(sourceBuilder);
Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Member Author

Choose a reason for hiding this comment

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

if we remove it the copy constructor would not be a correct copy constructor, meaning it would never copy the source? I think it's fine that it copies it and we override it when needed? WDYT?

Copy link
Member

Choose a reason for hiding this comment

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

Oh, I wasn't suggesting removing it in the copy constructor. I was missing the part that sourceBuilder here seems not be part of searchRequest yet when calling the copy constructor. All good now, thanks for the clarification.

@javanna javanna merged commit d2ce576 into elastic:master Dec 19, 2018
javanna added a commit that referenced this pull request Dec 19, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
>enhancement :Search/Search Search-related issues that do not fall into other categories v6.6.0 v7.0.0-beta1
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants