Skip to content

Allow fields calculated by scripting at index time #68984

@romseygeek

Description

@romseygeek

Runtime fields allow you to create a synthetic field derived from the values of other document properties at query time, which prioritises flexibility (you can change these fields at any time) over speed. This issue will address generating these synthetic fields at index time, trading off some of that flexibility for better query performance.

There should be as little impedance mismatch as possible between the scripts used for runtime fields and those used for index time calculations. Ideally, making a runtime field indexed should be as simple as moving the field definition from the runtime section of mappings into the properties section, eg:

"mappings" : {
  "runtime" : {
    "my_field" : {
      "type" : "long",
      "script" : " ... some script ... "
    }
  }
}

becomes:

"mappings" : {
  "properties" : {
    "my_field" : {
      "type" : "long",
      "script" : " ... some script ... "
    }
  }
}

In particular, we will need to reproduce the typed emit functions currently used by runtime scripts, and make _doc, _source and _fields available in the same way (although _fields is probably not a priority here as it essentially duplicates _source at index time).

Now that runtime fields have been moved to core, we can re-use their script factory implementations by mocking a lucene LeafReader over the contents of the parsed lucene Document that is to be indexed.

The steps to take are anticipated to be:

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions