Clean up has_parent query code Renamed some exception messages and removed method from builder
This commit is contained in:
parent
cfe76546f2
commit
9c04e6a4f4
|
@ -31,7 +31,6 @@ public class HasParentQueryBuilder extends BaseQueryBuilder implements Boostable
|
|||
private final QueryBuilder queryBuilder;
|
||||
private final String parentType;
|
||||
private String scope;
|
||||
private String filterName;
|
||||
private String executionType;
|
||||
private float boost = 1.0f;
|
||||
|
||||
|
@ -49,11 +48,6 @@ public class HasParentQueryBuilder extends BaseQueryBuilder implements Boostable
|
|||
return this;
|
||||
}
|
||||
|
||||
public HasParentQueryBuilder filterName(String filterName) {
|
||||
this.filterName = filterName;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Expert: Sets the low level parent to child filtering implementation. Can be: 'indirect' or 'uid'
|
||||
*
|
||||
|
@ -77,9 +71,6 @@ public class HasParentQueryBuilder extends BaseQueryBuilder implements Boostable
|
|||
if (scope != null) {
|
||||
builder.field("_scope", scope);
|
||||
}
|
||||
if (filterName != null) {
|
||||
builder.field("_name", filterName);
|
||||
}
|
||||
if (executionType != null) {
|
||||
builder.field("execution_type", executionType);
|
||||
}
|
||||
|
|
|
@ -72,7 +72,7 @@ public class HasParentQueryParser implements QueryParser {
|
|||
QueryParseContext.setTypes(origTypes);
|
||||
}
|
||||
} else {
|
||||
throw new QueryParsingException(parseContext.index(), "[has_parent] filter does not support [" + currentFieldName + "]");
|
||||
throw new QueryParsingException(parseContext.index(), "[has_parent] query does not support [" + currentFieldName + "]");
|
||||
}
|
||||
} else if (token.isValue()) {
|
||||
if ("type".equals(currentFieldName) || "parent_type".equals(currentFieldName) || "parentType".equals(currentFieldName)) {
|
||||
|
@ -84,24 +84,24 @@ public class HasParentQueryParser implements QueryParser {
|
|||
} else if ("boost".equals(currentFieldName)) {
|
||||
boost = parser.floatValue();
|
||||
} else {
|
||||
throw new QueryParsingException(parseContext.index(), "[has_parent] filter does not support [" + currentFieldName + "]");
|
||||
throw new QueryParsingException(parseContext.index(), "[has_parent] query does not support [" + currentFieldName + "]");
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!queryFound) {
|
||||
throw new QueryParsingException(parseContext.index(), "[parent] filter requires 'query' field");
|
||||
throw new QueryParsingException(parseContext.index(), "[parent] query requires 'query' field");
|
||||
}
|
||||
if (query == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (parentType == null) {
|
||||
throw new QueryParsingException(parseContext.index(), "[parent] filter requires 'parent_type' field");
|
||||
throw new QueryParsingException(parseContext.index(), "[parent] query requires 'parent_type' field");
|
||||
}
|
||||
|
||||
DocumentMapper parentDocMapper = parseContext.mapperService().documentMapper(parentType);
|
||||
if (parentDocMapper == null) {
|
||||
throw new QueryParsingException(parseContext.index(), "[parent] filter configured 'parent_type' [" + parentType + "] is not a valid type");
|
||||
throw new QueryParsingException(parseContext.index(), "[parent] query configured 'parent_type' [" + parentType + "] is not a valid type");
|
||||
}
|
||||
|
||||
query.setBoost(boost);
|
||||
|
|
Loading…
Reference in New Issue