Added an error message for when child mapping is not properly configured (incorrect type)
This commit is contained in:
parent
c37de66fb6
commit
abf2268574
|
@ -134,6 +134,10 @@ public class HasChildFilterParser implements FilterParser {
|
||||||
}
|
}
|
||||||
|
|
||||||
DocumentMapper parentDocMapper = parseContext.mapperService().documentMapper(parentType);
|
DocumentMapper parentDocMapper = parseContext.mapperService().documentMapper(parentType);
|
||||||
|
if (parentDocMapper == null) {
|
||||||
|
throw new QueryParsingException(parseContext.index(), "[has_child] Type [" + childType + "] points to a non existent parent type [" + parentType + "]");
|
||||||
|
}
|
||||||
|
|
||||||
Filter parentFilter = parseContext.cacheFilter(parentDocMapper.typeFilter(), null);
|
Filter parentFilter = parseContext.cacheFilter(parentDocMapper.typeFilter(), null);
|
||||||
HasChildFilter childFilter = new HasChildFilter(query, parentType, childType, parentFilter, searchContext);
|
HasChildFilter childFilter = new HasChildFilter(query, parentType, childType, parentFilter, searchContext);
|
||||||
searchContext.addRewrite(childFilter);
|
searchContext.addRewrite(childFilter);
|
||||||
|
|
|
@ -122,6 +122,10 @@ public class HasChildQueryParser implements QueryParser {
|
||||||
String parentType = childDocMapper.parentFieldMapper().type();
|
String parentType = childDocMapper.parentFieldMapper().type();
|
||||||
DocumentMapper parentDocMapper = parseContext.mapperService().documentMapper(parentType);
|
DocumentMapper parentDocMapper = parseContext.mapperService().documentMapper(parentType);
|
||||||
|
|
||||||
|
if (parentDocMapper == null) {
|
||||||
|
throw new QueryParsingException(parseContext.index(), "[has_child] Type [" + childType + "] points to a non existent parent type [" + parentType + "]");
|
||||||
|
}
|
||||||
|
|
||||||
// wrap the query with type query
|
// wrap the query with type query
|
||||||
SearchContext searchContext = SearchContext.current();
|
SearchContext searchContext = SearchContext.current();
|
||||||
if (searchContext == null) {
|
if (searchContext == null) {
|
||||||
|
|
Loading…
Reference in New Issue