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

NullPointer fix for field capabilities API #76742

Merged
merged 4 commits into from
Aug 23, 2021
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
Original file line number Diff line number Diff line change
Expand Up @@ -102,3 +102,19 @@ query:
- match: {aggregations.response.buckets.0.doc_count: 5 }
- match: {aggregations.response.buckets.1.key: 304 }
- match: {aggregations.response.buckets.1.doc_count: 1 }

---
"Field caps with composite runtime mappings section. Issue 76742":

- skip:
version: " - 7.14.99"
reason: Composite Runtime mappings support was added in 7.15

- do:
field_caps:
index: http_logs
fields: "*"

- match: {indices: ["http_logs"]}
- match: {fields.http\.response.long.type: long}
- match: {fields.http\.clientip.ip.type: ip}
Original file line number Diff line number Diff line change
Expand Up @@ -371,10 +371,13 @@ private FieldCapabilitiesIndexResponse shardOperation(final FieldCapabilitiesInd
if (searchExecutionContext.getFieldType(parentField) == null) {
// no field type, it must be an object field
ObjectMapper mapper = searchExecutionContext.getObjectMapper(parentField);
markharwood marked this conversation as resolved.
Show resolved Hide resolved
String type = mapper.isNested() ? "nested" : "object";
IndexFieldCapabilities fieldCap = new IndexFieldCapabilities(parentField, type,
// Composite runtime fields do not have a mapped type for the root - check for null
if (mapper != null) {
String type = mapper.isNested() ? "nested" : "object";
IndexFieldCapabilities fieldCap = new IndexFieldCapabilities(parentField, type,
false, false, false, Collections.emptyMap());
responseMap.put(parentField, fieldCap);
responseMap.put(parentField, fieldCap);
}
}
dotIndex = parentField.lastIndexOf('.');
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import org.elasticsearch.common.xcontent.NamedXContentRegistry;
import org.elasticsearch.common.xcontent.XContentParser;
import org.elasticsearch.core.CheckedFunction;
import org.elasticsearch.core.Nullable;
import org.elasticsearch.index.Index;
import org.elasticsearch.index.IndexSettings;
import org.elasticsearch.index.IndexSortConfig;
Expand Down Expand Up @@ -365,6 +366,12 @@ private MappedFieldType fieldType(String name) {
return fieldType == null ? mappingLookup.getFieldType(name) : fieldType;
}

/**
*
* @param name name of the object
* @return can be null e.g. if field is root of a composite runtime field
*/
@Nullable
public ObjectMapper getObjectMapper(String name) {
return mappingLookup.objectMappers().get(name);
}
Expand Down