Refactored inner hits parsing and intoduced InnerHitBuilder#17291
Refactored inner hits parsing and intoduced InnerHitBuilder#17291martijnvg merged 1 commit intoelastic:masterfrom
Conversation
There was a problem hiding this comment.
Could you also check for null here?
|
@martijnvg this looks great, even though I didn't compare it completely to the way it was before the refactoring, I have the feeling this change simplifies a lot. Left a few minor comments, only thing that was causing some trouble with the tests on my side was the |
d9081b5 to
1b36a9e
Compare
|
@cbuescher Thanks for looking at this. I updated the PR based on your comment and fixed the |
|
With top-level I'm thinking that something like this will work; is there a better way? |
|
@dimfeld Yes, that should work too. Also I'm thinking of also allowing the This would be better, because it would be more efficient as only one The goal with replacing inner hits is that same things can be done with inline inner hits as top level inner hits. |
1b36a9e to
d453f70
Compare
|
Sounds good. Thanks @martijnvg! |
|
@martijnvg thanks, changes look great and all works for me now, but maybe @colings86, @javanna or @s1monw want to take a second look at this before it gets in. |
There was a problem hiding this comment.
I wonder if we should add validation check to these setter methods like we do in the query builders? So for this one check that the value is >= 0 and for setName() make sure the name passed in is not null.
|
@martijnvg I left a few minor comments but otherwise it LGTM |
There was a problem hiding this comment.
I'm curious about why this reset (and the one in the finally block) are done. I saw this pattern in other places, just trying to figure out why this is done. In case its important, maybe worth a comment?
There was a problem hiding this comment.
This is the same logic in QueryShardContext#toQuery() where we reset also twice. Personally I think a reset at the end is sufficient, but I kept the logic consistent with this method.
The reason we need to invoke reset at all here is because inner hits modifies the QueryShardContext#nestedScope, so we need to reset at the end.
There was a problem hiding this comment.
Thanks for the explanation, I've been looking at resets in shard contexts recently and this helps my understanding.
|
@martijnvg I did another quick round, left a few minor suggestions and one question for my own understanding. |
Both top level and inline inner hits are now covered by InnerHitBuilder.
Although there are differences between top level and inline inner hits,
they now make use of the same builder logic.
The parsing of top level inner hits slightly changed to be more readable.
Before the nested path or parent/child type had to be specified as encapsuting
json object, now these settings are simple fields. Before this was required
to allow streaming parsing of inner hits without missing contextual information.
Once some issues are fixed with inline inner hits (around multi level hierachy of inner hits),
top level inner hits will be deprecated and removed in the next major version.
Also I think some
SearchParseElementimplementations can be removed, but I haven't done that yet.