-
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
Changes from 3 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 commentThe 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? |
||
this(other); | ||
this.query = query; | ||
this.parentChildType = parentChildType; | ||
|
@@ -751,7 +752,8 @@ public static void extractInnerHits(QueryBuilder query, Map<String, InnerHitBuil | |
} | ||
} | ||
|
||
static InnerHitBuilder rewrite(InnerHitBuilder original, QueryBuilder rewrittenQuery) { | ||
// TODO public for hasParent and hasChild query | ||
public static InnerHitBuilder rewrite(InnerHitBuilder original, QueryBuilder rewrittenQuery) { | ||
if (original == null) { | ||
return null; | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -26,7 +26,6 @@ | |
import org.apache.lucene.search.highlight.WeightedSpanTermExtractor; | ||
import org.elasticsearch.common.lucene.search.function.FiltersFunctionScoreQuery; | ||
import org.elasticsearch.common.lucene.search.function.FunctionScoreQuery; | ||
import org.elasticsearch.index.query.HasChildQueryBuilder; | ||
|
||
import java.io.IOException; | ||
import java.util.Map; | ||
|
@@ -83,7 +82,7 @@ protected void extractUnknownQuery(Query query, | |
} | ||
|
||
protected void extract(Query query, float boost, Map<String, WeightedSpanTerm> terms) throws IOException { | ||
if (query instanceof HasChildQueryBuilder.LateParsingQuery) { | ||
if (isChildOrParentQuery(query.getClass())) { | ||
// skip has_child or has_parent queries, see: https://github.com/elastic/elasticsearch/issues/14999 | ||
return; | ||
} else if (query instanceof FunctionScoreQuery) { | ||
|
@@ -94,5 +93,13 @@ protected void extract(Query query, float boost, Map<String, WeightedSpanTerm> t | |
super.extract(query, boost, terms); | ||
} | ||
} | ||
|
||
/** | ||
* 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 commentThe 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 boolean isChildOrParentQuery(Class<?> clazz) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 commentThe reason will be displayed to describe this comment to others. Learn more. We have a test for this in |
||
return clazz.getName().endsWith(PARENT_CHILD_QUERY_NAME); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. maybe do this:
? |
||
} | ||
} | ||
} |
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.
👍