DRAFT: Add the ability to run scripts to build fields at index time #68681
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
External API: Field mapper definitions get an added 'script' parameter (currently implemented only for numerics):
An input source containing a 'message_length' field throws an error at parse time.
Internal API: Mappers get a 'postParse()' method, which is called on the root mapper once all normal parsing is done and propagates through the mapper tree. Mappers with scripts execute them at this point. The scripts don't share any code with their runtime equivalents, but expose the same context -
_source(just a source lookup built from the input document),emit()anddoc. The latter is constructed using value fetchers, which results in some changes to this internal API: specifically, MappedFieldType.valueFetcher() now takes a function to expand source paths, rather than a SearchExecutionContext (because we have no SEC at index time); and ValueFetcher.fetchValues() now takes a ValuesLookup rather than just a SourceLookup, which includes field data as well.