Skip to content

Commit 18d66b0

Browse files
committed
Modify to invoke QueryShardContext.fieldMapper() method to apply allowUnmappedFields and mapUnmappedFieldAsString settings
Signed-off-by: imyp92 <pyw5420@gmail.com>
1 parent 581fcd2 commit 18d66b0

File tree

2 files changed

+4
-8
lines changed

2 files changed

+4
-8
lines changed

server/src/main/java/org/opensearch/index/query/ExistsQueryBuilder.java

+3-7
Original file line numberDiff line numberDiff line change
@@ -230,20 +230,16 @@ private static Collection<String> getMappedField(QueryShardContext context, Stri
230230
if (context.getObjectMapper(fieldPattern) != null) {
231231
// the _field_names field also indexes objects, so we don't have to
232232
// do any more work to support exists queries on whole objects
233-
fields = Collections.singleton(fieldPattern);
233+
return Collections.singleton(fieldPattern);
234234
} else {
235235
fields = context.simpleMatchToIndexNames(fieldPattern);
236236
}
237237

238238
if (fields.size() == 1) {
239239
String field = fields.iterator().next();
240-
MappedFieldType fieldType = context.getMapperService().fieldType(field);
240+
MappedFieldType fieldType = context.fieldMapper(field);
241241
if (fieldType == null) {
242-
// The field does not exist as a leaf but could be an object so
243-
// check for an object mapper
244-
if (context.getObjectMapper(field) == null) {
245-
return Collections.emptySet();
246-
}
242+
return Collections.emptySet();
247243
}
248244
}
249245

server/src/main/java/org/opensearch/index/search/QueryParserHelper.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ static Map<String, Float> resolveMappingField(
143143
fieldName = fieldName + fieldSuffix;
144144
}
145145

146-
MappedFieldType fieldType = context.getMapperService().fieldType(fieldName);
146+
MappedFieldType fieldType = context.fieldMapper(fieldName);
147147
if (fieldType == null) {
148148
continue;
149149
}

0 commit comments

Comments
 (0)