-
Notifications
You must be signed in to change notification settings - Fork 24.4k
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
Add parent-join module #24638
Add parent-join module #24638
Conversation
This change adds a new module named `parent-join`. The goal of this module is to provide a replacement for the `_parent` field but as a first step this change only moves the `has_child`, `has_parent` queries and the `children` aggregation to this module. These queries and aggregations are no longer in core but they are deployed by default as a module. Relates elastic#20257
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 had a look out of curiosity, I'm curious what @martijnvg thinks.
* Workaround to detect parent/child query | ||
*/ | ||
private static final String PARENT_CHILD_QUERY_NAME = "HasChildQueryBuilder$LateParsingQuery"; | ||
private static boolean isChildOrParentQuery(Class<?> clazz) { |
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.
Maybe make this method public and test in the parent join module that it actually detects this query?
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.
We have a test for this in ChildQuerySearchIT#testHighlighHighlightersIgnoreParentChild
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.
Looks great! I left some small comments.
import org.apache.lucene.search.join.ScoreMode; | ||
import org.elasticsearch.index.query.QueryBuilder; | ||
|
||
public abstract class JoinQueryBuilders { |
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.
maybe change this into an enum? So that no subclasses can ever by created.
|
||
package org.elasticsearch.join.aggregations; | ||
|
||
public abstract class JoinAggregationBuilders { |
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.
maybe change this into an enum? So that no subclasses can ever by created.
import java.util.List; | ||
|
||
public class ParentJoinPlugin extends Plugin implements SearchPlugin { | ||
private final Settings settings; |
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.
maybe remove settings
fields? because it is unused.
@@ -620,7 +620,6 @@ | |||
<suppress files="core[/\\]src[/\\]test[/\\]java[/\\]org[/\\]elasticsearch[/\\]index[/\\]query[/\\]BoolQueryBuilderTests.java" checks="LineLength" /> | |||
<suppress files="core[/\\]src[/\\]test[/\\]java[/\\]org[/\\]elasticsearch[/\\]index[/\\]query[/\\]BoostingQueryBuilderTests.java" checks="LineLength" /> | |||
<suppress files="core[/\\]src[/\\]test[/\\]java[/\\]org[/\\]elasticsearch[/\\]index[/\\]query[/\\]GeoDistanceQueryBuilderTests.java" checks="LineLength" /> | |||
<suppress files="core[/\\]src[/\\]test[/\\]java[/\\]org[/\\]elasticsearch[/\\]index[/\\]query[/\\]HasChildQueryBuilderTests.java" checks="LineLength" /> |
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.
👍
@@ -195,7 +195,8 @@ private InnerHitBuilder(InnerHitBuilder other) { | |||
} | |||
} | |||
|
|||
InnerHitBuilder(InnerHitBuilder other, QueryBuilder query, String parentChildType, boolean ignoreUnmapped) { | |||
// TODO public for hasChild and hasParent query. | |||
public InnerHitBuilder(InnerHitBuilder other, QueryBuilder query, String parentChildType, boolean ignoreUnmapped) { |
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.
maybe add a note that these methods are for internal usage only and no one should rely on this method to remain to be available?
/** | ||
* Workaround to detect parent/child query | ||
*/ | ||
private static final String PARENT_CHILD_QUERY_NAME = "HasChildQueryBuilder$LateParsingQuery"; |
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.
not so pretty... but I'm not sure how this check can be achieved in a better way.
*/ | ||
private static final String PARENT_CHILD_QUERY_NAME = "HasChildQueryBuilder$LateParsingQuery"; | ||
private static boolean isChildOrParentQuery(Class<?> clazz) { | ||
return clazz.getName().endsWith(PARENT_CHILD_QUERY_NAME); |
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.
maybe do this:
return clazz.getSimpeName().equals(PARENT_CHILD_QUERY_NAME)
?
@jimczi One other question: i don't think this needs to be pushed into the 5.x branch? |
if we can introduce it in 5.x to allow people to start adjusting their applications now, that would be preferable. |
Thanks for reviewing @martijnvg and @jpountz |
…Child and hasParent in the tests
* Add parent-join module This change adds a new module named `parent-join`. The goal of this module is to provide a replacement for the `_parent` field but as a first step this change only moves the `has_child`, `has_parent` queries and the `children` aggregation to this module. These queries and aggregations are no longer in core but they are deployed by default as a module. Relates #20257
This change adds a new module named parent-join.
The goal of this module is to provide a replacement for the _parent field but as a first step this change only moves the has_child, has_parent queries and the children aggregation to this module.
These queries and aggregations are no longer in core but they are deployed by default as a module.
Relates #20257