elasticsearch icon indicating copy to clipboard operation
elasticsearch copied to clipboard

Don't modify source map when parsing composite runtime field

Open romseygeek opened this issue 2 years ago • 4 comments

When calling RuntimeField.parseRuntimeFields() for fields defined in the search request, we need to wrap the Map containing field definitions in another Map that supports value removal, so that we don't inadvertently remove the definitions from the root request. CompositeRuntimeField was not doing this extra wrapping, which meant that requests that went to multiple shards and that therefore parsed the definitions multiple times would throw an error complaining that the fields parameter was missing, because the root request had been modified.

romseygeek avatar Aug 04 '22 11:08 romseygeek

Pinging @elastic/es-search (Team:Search)

elasticsearchmachine avatar Aug 04 '22 11:08 elasticsearchmachine

Hi @romseygeek, I've created a changelog YAML for you.

elasticsearchmachine avatar Aug 04 '22 11:08 elasticsearchmachine

OK this doesn't quite work because we need to distinguish between parsing at mapping time or at search time within the composite field as well. I'm digging further...

romseygeek avatar Aug 04 '22 12:08 romseygeek

Actually it looks as though it was a bug in serialization that wasn't caught before because the fields map was being emptied at parse time and so the unnecessary code to output it never actually got triggered. This is ready for review now @javanna

romseygeek avatar Aug 04 '22 13:08 romseygeek

@elasticmachine update branch

romseygeek avatar Aug 15 '22 08:08 romseygeek