Renaming Values

Hi there,

Is there away to rename values within visuals?
so for example filtering Colors which outputs 1 , 2
I want to rename these 1 == 'Red' 2== 'Blue' etc.

Though I'm not sure these are only ways, you may use runtime fields to manipulate the values.

Or of cource you may do it outside elasticsearch while indexing.

PUT /test_map
{
  "mappings": {
    "properties": {
      "colorId":{
        "type":"keyword"
      }
    }
  }
}
PUT /test_map/_bulk
{"index":{}}
{"colorId":"1"}
{"index":{}}
{"colorId":"2"}

GET /test_map/_search
{
  "runtime_mappings": {
    "colorName": {
      "type": "keyword",
      "script": {
        "source": """
        for (val in doc['colorId']){
          emit(params.map[val])
        }
        """,
        "params":{
          "map":{
            "1": "Red",
            "2": "Blue"
          }
        }
      }
    }
  },
  "fields": [
    "colorName"
  ]
}
1 Like

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.