How to convert string field to number using painless script to visualize in kibana

Hello
I am trying to convert a string field to number.
This string field contains mainly floated point values like "127.5", "218.3" etc, etc.

I appreciate any advice in advance .

Hi,

Did you try to look at field formatters in Kibana to see if that helps?
https://www.elastic.co/guide/en/kibana/current/managing-fields.html

Thanks,
Bhavya

Hi,
Yes this is the only way it worked. But i wanted to find a way to do this without touch the "Index Pattern" .

I thought i could do this by a scripted_field.

Thanks
Vafa

You can. But scripted fields are expensive operation.

Thanks,
Bhavya

Hi Vafa,
The best advice I can give is to create template which include mapping for each field,
And rebuild the indices.

Thanks, I will try this .

Kind Regards
Vafa

{
"metrics" : {
"order" : 0,
"index_patterns" : [
"metrics"
],
"settings" : {
"index" : {
"number_of_shards" : "5",
"number_of_replicas" : "0"
}
},
"mappings" : {
"doc" : {
"properties" : {
" count" : {
"type" : "long",
"fields" : {
"keyword" : {
"type" : "keyword",
"ignore_above" : 256
}
}
},
"duration_unit" : {
"type" : "text",
"fields" : {
"keyword" : {
"type" : "keyword",
"ignore_above" : 256
}
}
}

here there is small example.
pay attention to include the index pattern you want to include changes

1 Like

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