Kibana - Translate Filter Options

Hi,

I am using 7.6 version
I have a use case, in an Index, a Field will have Integer values, it has to mapped to Text when displayed as Filter in Kibana and this Text will also need to be translatable in two languages.
eg:
Index : sample (with field status)
status: 1,2,3

When I display filter in Kibana, Status need to be [1:WON,2:REJECTED,3:CANCELED]

Is this possible in the Kibana? I have checked the Translation plugins which translates the Kibana Application only.

Is there feature/plugin to achieve this?

Thanks in advance.

Hey @charlz, welcome to the discussion boards!

Kibana can't translate your user-supplied data on its own, but you can accomplish this with data enrichment when you ingest the data into Elasticsearch.

There are a couple of high-level steps:

Define an enrichment index

This index will be a mapping between your status id, and the various translations you're interested in. I chose English and Spanish, but you can do whatever you'd like. Here is an example of the three status codes you provided, being created in the enrich_status index:

POST enrich_status/_doc
{
  "status": 1,
  "status_en": "WON",
  "status_es": "GANAR"
}

POST enrich_status/_doc
{
  "status": 2,
  "status_en": "REJECTED",
  "status_es": "RECHAZADA"
}

POST enrich_status/_doc
{
  "status": 3,
  "status_en": "CANCELED",
  "status_es": "CANCELADA"
}

Create an enrichment policy

I followed this example to create a policy to match based on the status field:

PUT /_enrich/policy/status-policy
{
    "match": {
        "indices": "enrich_status",
        "match_field": "status",
        "enrich_fields": ["status_en", "status_es"]
    }
}

POST /_enrich/policy/status-policy/_execute

PUT /_ingest/pipeline/status_lookup
{
  "description" : "Enriching status details",
  "processors" : [
    {
      "enrich" : {
        "policy_name": "status-policy",
        "field" : "status",
        "target_field": "details",
        "max_matches": "1"
      }
    }
  ]
}

Ingest your data

Now, when you index data into Elasticsearch, specify the status_lookup pipeline:

PUT /my_charlz_index/_doc/my_id?pipeline=status_lookup
{
  "status": 1
}

Then, when you search this index, you'll find that all the relevant details from the enrich_status index have been copied into your target index:

GET /my_charlz_index/_search
{
  "took" : 0,
  "timed_out" : false,
  "_shards" : {
    "total" : 1,
    "successful" : 1,
    "skipped" : 0,
    "failed" : 0
  },
  "hits" : {
    "total" : {
      "value" : 1,
      "relation" : "eq"
    },
    "max_score" : 1.0,
    "hits" : [
      {
        "_index" : "my_charlz_index",
        "_type" : "_doc",
        "_id" : "my_id",
        "_score" : 1.0,
        "_source" : {
          "details" : {
            "status_es" : "GANAR",
            "status_en" : "WON",
            "status" : 1
          },
          "status" : 1
        }
      }
    ]
  }
}

Thanks @Larry_Gregory.

Considering the factor of using the Ingest might be expensive in-terms of Indexing Document, if the Document is structured with similar way without using Ingest will that be good solution to be considered instead of Ingest(Enrich)? . Your thoughts please?

 POST enrich_status/_doc
{
  "status": 1,
  "status_en": "WON",
  "status_es": "GANAR"
} 
POST enrich_status/_doc
{
  "status":{
       "status_value": 1,
       "status_en": "WON",
       "status_es": "GANAR"
   }
} 

Does this Document Structure or using the Ingest(Enrich) on Field will help in building the Dashboards much better in terms of indexing and performance?

Sorry for the delayed response. Yes, if you're able to change the structure of the document you're ingesting, then that would be more performant than asking Elasticsearch to do so at ingest time

Thanks Larry, I have chosen to change the Structure.

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