Hi, I'm trying to index a field in elasticsearch with my index template. Except that my field can either be of type text (ex: No) or it can be of type float ( ex: 8.1). When I set the type to float in my mapping, I get errors parsing text values. I tried to define the type as "keyword". but when I want to create a data table visualization in kibana and I want to choose the range metric, I can't use my field because the range metric only works on numeric values. How can I proceed?
You need to split the text content and the numbers into 2 fields.
It's better if you can do that before sending the data to Elasticsearch.
Otherwise, you can create an ingest pipeline which converts the foo
field to a float
into a foo_float
field. If you add ignore_failure: true
, the field won't be created if not a number.
PUT _ingest/pipeline/to-float
{
"processors" : [
{
"convert" : {
"field" : "foo",
"target_field" : "foo_float",
"type": "float",
"ignore_failure": true
}
}
]
}
This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.