Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public class HasParentQueryBuilder extends AbstractQueryBuilder<HasParentQueryBu
public static final boolean DEFAULT_IGNORE_UNMAPPED = false;

private static final ParseField QUERY_FIELD = new ParseField("query");
private static final ParseField TYPE_FIELD = new ParseField("parent_type");
private static final ParseField PARENT_TYPE_FIELD = new ParseField("parent_type");
private static final ParseField SCORE_FIELD = new ParseField("score");
private static final ParseField INNER_HITS_FIELD = new ParseField("inner_hits");
private static final ParseField IGNORE_UNMAPPED_FIELD = new ParseField("ignore_unmapped");
Expand All @@ -74,8 +74,8 @@ public HasParentQueryBuilder(String type, QueryBuilder query, boolean score) {
}

private HasParentQueryBuilder(String type, QueryBuilder query, boolean score, InnerHitBuilder innerHitBuilder) {
this.type = requireValue(type, "[" + NAME + "] requires 'type' field");
this.query = requireValue(query, "[" + NAME + "] requires 'query' field");
this.type = requireValue(type, "[" + NAME + "] requires '" + PARENT_TYPE_FIELD.getPreferredName() + "' field");
this.query = requireValue(query, "[" + NAME + "] requires '" + QUERY_FIELD.getPreferredName() + "' field");
this.score = score;
this.innerHitBuilder = innerHitBuilder;
}
Expand Down Expand Up @@ -201,7 +201,7 @@ protected void doXContent(XContentBuilder builder, Params params) throws IOExcep
builder.startObject(NAME);
builder.field(QUERY_FIELD.getPreferredName());
query.toXContent(builder, params);
builder.field(TYPE_FIELD.getPreferredName(), type);
builder.field(PARENT_TYPE_FIELD.getPreferredName(), type);
builder.field(SCORE_FIELD.getPreferredName(), score);
builder.field(IGNORE_UNMAPPED_FIELD.getPreferredName(), ignoreUnmapped);
printBoostAndQueryName(builder);
Expand Down Expand Up @@ -235,7 +235,7 @@ public static HasParentQueryBuilder fromXContent(XContentParser parser) throws I
"[has_parent] query does not support [" + currentFieldName + "]");
}
} else if (token.isValue()) {
if (TYPE_FIELD.match(currentFieldName, parser.getDeprecationHandler())) {
if (PARENT_TYPE_FIELD.match(currentFieldName, parser.getDeprecationHandler())) {
parentType = parser.text();
} else if (SCORE_FIELD.match(currentFieldName, parser.getDeprecationHandler())) {
score = parser.booleanValue();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ public void testIllegalValues() throws IOException {
QueryBuilder query = new MatchAllQueryBuilder();
IllegalArgumentException e = expectThrows(IllegalArgumentException.class,
() -> hasParentQuery(null, query, false));
assertThat(e.getMessage(), equalTo("[has_parent] requires 'type' field"));
assertThat(e.getMessage(), equalTo("[has_parent] requires 'parent_type' field"));

e = expectThrows(IllegalArgumentException.class,
() -> hasParentQuery("foo", null, false));
Expand Down