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

Add parent-join module #24638

Merged
merged 4 commits into from
May 12, 2017
Merged

Add parent-join module #24638

merged 4 commits into from
May 12, 2017

Conversation

jimczi
Copy link
Contributor

@jimczi jimczi commented May 12, 2017

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 elastic#20257
Copy link
Contributor

@jpountz jpountz left a 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) {
Copy link
Contributor

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?

Copy link
Contributor Author

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

Copy link
Member

@martijnvg martijnvg left a 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 {
Copy link
Member

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 {
Copy link
Member

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;
Copy link
Member

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" />
Copy link
Member

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) {
Copy link
Member

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";
Copy link
Member

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);
Copy link
Member

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)

?

@martijnvg
Copy link
Member

@jimczi One other question: i don't think this needs to be pushed into the 5.x branch?

@clintongormley
Copy link

@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.

@jimczi jimczi merged commit 279a18a into elastic:master May 12, 2017
@jimczi jimczi deleted the modules/parent_join branch May 12, 2017 13:58
@jimczi
Copy link
Contributor Author

jimczi commented May 12, 2017

Thanks for reviewing @martijnvg and @jpountz
I'll wait a bit before back porting this to 5.x

jimczi added a commit that referenced this pull request May 12, 2017
jimczi added a commit that referenced this pull request May 12, 2017
jimczi added a commit that referenced this pull request May 16, 2017
* 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
jimczi added a commit that referenced this pull request May 16, 2017
@clintongormley clintongormley added :Search/Search Search-related issues that do not fall into other categories and removed :Parent/Child labels Feb 14, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
>non-issue :Search/Search Search-related issues that do not fall into other categories v5.5.0 v6.0.0-beta1
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants