Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix allowUnmappedFields, mapUnmappedFieldAsString settings to be applied when parsing query string query #13957

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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
- Remove query categorization changes ([#14759](https://github.com/opensearch-project/OpenSearch/pull/14759))

### Fixed
- Fix allowUnmappedFields, mapUnmappedFieldAsString settings are not applied when parsing certain types of query string query ([#13957](https://github.com/opensearch-project/OpenSearch/pull/13957))
- Fix bug in SBP cancellation logic ([#13259](https://github.com/opensearch-project/OpenSearch/pull/13474))
- Fix handling of Short and Byte data types in ScriptProcessor ingest pipeline ([#14379](https://github.com/opensearch-project/OpenSearch/issues/14379))
- Switch to iterative version of WKT format parser ([#14086](https://github.com/opensearch-project/OpenSearch/pull/14086))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,3 +83,48 @@
index: documents_index
id: some_id
- match: { responses.0.hits.total: 1 }

- do:
catch: bad_request
index:
index: queries_index
body:
query:
query_string:
query: "unmapped: *"

- do:
catch: bad_request
index:
index: queries_index
body:
query:
query_string:
query: "_exists_: unmappedField"

- do:
catch: bad_request
index:
index: queries_index
body:
query:
query_string:
query: "unmappedField: <100"

- do:
catch: bad_request
index:
index: queries_index
body:
query:
query_string:
query: "unmappedField: test~"

- do:
catch: bad_request
index:
index: queries_index
body:
query:
query_string:
query: "unmappedField: test*"
Original file line number Diff line number Diff line change
Expand Up @@ -230,20 +230,16 @@ private static Collection<String> getMappedField(QueryShardContext context, Stri
if (context.getObjectMapper(fieldPattern) != null) {
// the _field_names field also indexes objects, so we don't have to
// do any more work to support exists queries on whole objects
fields = Collections.singleton(fieldPattern);
return Collections.singleton(fieldPattern);
} else {
fields = context.simpleMatchToIndexNames(fieldPattern);
}

if (fields.size() == 1) {
String field = fields.iterator().next();
MappedFieldType fieldType = context.getMapperService().fieldType(field);
MappedFieldType fieldType = context.fieldMapper(field);
if (fieldType == null) {
// The field does not exist as a leaf but could be an object so
// check for an object mapper
if (context.getObjectMapper(field) == null) {
return Collections.emptySet();
}
return Collections.emptySet();
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ static Map<String, Float> resolveMappingField(
fieldName = fieldName + fieldSuffix;
}

MappedFieldType fieldType = context.getMapperService().fieldType(fieldName);
MappedFieldType fieldType = context.fieldMapper(fieldName);
gaobinlong marked this conversation as resolved.
Show resolved Hide resolved
if (fieldType == null) {
fieldType = context.resolveDerivedFieldType(fieldName);
}
Expand Down
Loading