mirror of
https://github.com/honeymoose/OpenSearch.git
synced 2025-02-08 05:58:44 +00:00
top_children query returns no results when child field has the same name as a nested field as a nested field in the parent mapping, closes #1709.
This commit is contained in:
parent
a336886464
commit
94d64c0be4
@ -63,6 +63,7 @@ public class HasChildFilterParser implements FilterParser {
|
|||||||
currentFieldName = parser.currentName();
|
currentFieldName = parser.currentName();
|
||||||
} else if (token == XContentParser.Token.START_OBJECT) {
|
} else if (token == XContentParser.Token.START_OBJECT) {
|
||||||
if ("query".equals(currentFieldName)) {
|
if ("query".equals(currentFieldName)) {
|
||||||
|
// TODO we need to set the type, but, `query` can come before `type`...
|
||||||
// since we switch types, make sure we change the context
|
// since we switch types, make sure we change the context
|
||||||
String[] origTypes = QueryParseContext.setTypesWithPrevious(childType == null ? null : new String[]{childType});
|
String[] origTypes = QueryParseContext.setTypesWithPrevious(childType == null ? null : new String[]{childType});
|
||||||
try {
|
try {
|
||||||
|
@ -63,6 +63,7 @@ public class HasChildQueryParser implements QueryParser {
|
|||||||
currentFieldName = parser.currentName();
|
currentFieldName = parser.currentName();
|
||||||
} else if (token == XContentParser.Token.START_OBJECT) {
|
} else if (token == XContentParser.Token.START_OBJECT) {
|
||||||
if ("query".equals(currentFieldName)) {
|
if ("query".equals(currentFieldName)) {
|
||||||
|
// TODO we need to set the type, but, `query` can come before `type`... (see HasChildFilterParser)
|
||||||
// since we switch types, make sure we change the context
|
// since we switch types, make sure we change the context
|
||||||
String[] origTypes = QueryParseContext.setTypesWithPrevious(childType == null ? null : new String[]{childType});
|
String[] origTypes = QueryParseContext.setTypesWithPrevious(childType == null ? null : new String[]{childType});
|
||||||
try {
|
try {
|
||||||
|
@ -65,7 +65,14 @@ public class TopChildrenQueryParser implements QueryParser {
|
|||||||
currentFieldName = parser.currentName();
|
currentFieldName = parser.currentName();
|
||||||
} else if (token == XContentParser.Token.START_OBJECT) {
|
} else if (token == XContentParser.Token.START_OBJECT) {
|
||||||
if ("query".equals(currentFieldName)) {
|
if ("query".equals(currentFieldName)) {
|
||||||
|
// TODO we need to set the type, but, `query` can come before `type`... (see HasChildFilterParser)
|
||||||
|
// since we switch types, make sure we change the context
|
||||||
|
String[] origTypes = QueryParseContext.setTypesWithPrevious(childType == null ? null : new String[]{childType});
|
||||||
|
try {
|
||||||
query = parseContext.parseInnerQuery();
|
query = parseContext.parseInnerQuery();
|
||||||
|
} finally {
|
||||||
|
QueryParseContext.setTypes(origTypes);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
throw new QueryParsingException(parseContext.index(), "[top_children] query does not support [" + currentFieldName + "]");
|
throw new QueryParsingException(parseContext.index(), "[top_children] query does not support [" + currentFieldName + "]");
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user