Skip to content

Add support for ephemeral runtime fields #61298

@javanna

Description

@javanna

Once we have added support for runtime fields added to index mappings (#59332), we'd like to make it possible to make them available in the context of a specific search request. A new section of the search request would be added, which allows to create runtime fields on-the-fly. In that case such fields are available only within the execution of that specific search request.

The following is an example of how a runtime scripted field can be made available in the context of a search request:

GET my_index/_search
{
    "runtime_mappings": {
        "age": { 
            "type" : "runtime_script",
            "runtime_type": "integer", 
            "script": {
                "source" : "now - doc['date_of_birth'].value"
            }
        }
    },
    "query": {
        "range" : {
            "age" : {
                "gte" : 10,
                "lte" : 20
            }
        }
    },
    "sort" : ["age"],
    "aggs" : {
        "age" : {
            "terms" : {
                "field" : "age"
            }
        }
    }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions