Skip to content

Conversation

@romseygeek
Copy link
Contributor

External API: Field mapper definitions get an added 'script' parameter (currently implemented only for numerics):

"properties" : {
    "message_length" : {
        "type" : "long",
        "script" : "emit(doc['message'].length())"
    }
}

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() and doc. 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.

@romseygeek romseygeek marked this pull request as draft February 8, 2021 16:28
@romseygeek
Copy link
Contributor Author

I should point out that there are a couple of refactorings that we can do in separate parts here to prepare for the new functionality, which will make the final thing easier to review:

  • Change the parameter onValueFetcher.fetchValues from SourceLookup to ValuesLookup
  • Change the parameter on MappedFieldType.valueFetcher from SearchExecutionContext to Function<String, Set<String>>

@romseygeek
Copy link
Contributor Author

Closing in favour of #69531

@romseygeek romseygeek closed this Feb 24, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant