Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add runtime_mappings to the top level of request_body #1310

Closed
Leaf-Lin opened this issue Sep 8, 2023 · 1 comment
Closed

Add runtime_mappings to the top level of request_body #1310

Leaf-Lin opened this issue Sep 8, 2023 · 1 comment

Comments

@Leaf-Lin
Copy link
Contributor

Leaf-Lin commented Sep 8, 2023

The problem

It would be great to have runtime_mappings available at the top-level elasticsearch query request body. This is similar to the enhancement request described in #130

Details

In Elasticsearch, runtime_mappings may be used to define fields not currently available in the documents. This is related to #1309 where the output of the runtime fields also needs to be available for display and filter.

An example can be found in https://www.elastic.co/guide/en/elasticsearch/reference/current/runtime-search-request.html

GET my-index-000001/_search
{
  "runtime_mappings": {
    "day_of_week": {
      "type": "keyword",
      "script": {
        "source": "emit(doc['@timestamp'].value.dayOfWeekEnum.getDisplayName(TextStyle.FULL, Locale.ROOT))"
      }
    }
  },
  "aggs": {
    "day_of_week": {
      "terms": {
        "field": "day_of_week"
      }
    }
  }
}

Map a runtime field in the mappings wouldn't have helped in my use case because my runtime_mappings depends on the query input.

GET my-index-000001/_search
{
  "runtime_mappings": {
    "query_input": {
      "type": "double",
      "script": {
        "source": "emit(query_input*2)"
      }
    }
  }
}
@joemcelroy
Copy link
Member

runtime support was added. See documentation https://www.searchkit.co/docs/api-documentation/searchkit#search_settings-configuration

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

No branches or pull requests

2 participants