Store source for fields in objects with dynamic override#108911
Store source for fields in objects with dynamic override#108911elasticsearchmachine merged 10 commits intoelastic:mainfrom
dynamic override#108911Conversation
|
Hi @kkrik-es, I've created a changelog YAML for you. |
|
@elasticsearchmachine update branch |
|
Pinging @elastic/es-storage-engine (Team:StorageEngine) |
|
|
||
| private static void parseArrayDynamic(DocumentParserContext context, String currentFieldName) throws IOException { | ||
| ensureNotStrict(context, currentFieldName); | ||
| if (context.dynamic() == ObjectMapper.Dynamic.FALSE) { |
There was a problem hiding this comment.
I sent #108912 for this change, it's orthogonal.
… into fix/synthetic-source/no-dynamic
# Conflicts: # server/src/main/java/org/elasticsearch/index/mapper/DocumentParser.java
| && fieldMapper.syntheticSourceMode() == FieldMapper.SyntheticSourceMode.FALLBACK; | ||
| if (storeArraySourceEnabled || fieldWithFallbackSyntheticSource || mapper instanceof NestedObjectMapper) { | ||
| if (context.canAddIgnoredField()) { | ||
| if ((mapper instanceof ObjectMapper objectMapper |
There was a problem hiding this comment.
nit: i do prefer named booleans here
There was a problem hiding this comment.
Not a huge fan but happy to entertain your preference.
| // field defined as runtime field, don't index anything | ||
| // Run-time fields are mapped to this mapper, so it needs to handle storing values for use in synthetic source. | ||
| // #parseValue calls this method once the run-time field is created. | ||
| if (context.dynamic() == ObjectMapper.Dynamic.RUNTIME && context.canAddIgnoredField()) { |
There was a problem hiding this comment.
It is not clear to me which code path leads to this and does not have source already stored at DocumentParser level. E.g. if canAddIgnoredField is true we would have already stored source inside parseObjectDynamic right after creating this mapper, meaning canAddIgnoredField is always false here.
There was a problem hiding this comment.
Took me a while to capture this.. When a new runtime field is created, we go through the path in parseDynamicValue in the master. Then, in the data node, the forwarded mapping contains the runtime field so this code executes; parseValue calls parseObjectOrField with this mapper, instead of parseDynamicValue.
Covers setting
dynamictofalseorruntime.Related to #106825, #108417