How to convert json string to number

Hi All,

I am sending custom json string with the help of http rest call. When index is created, the document is having string type for all kind of fields. there are few numeric values as well and I want to convert those fields to number instead of string.
Please let me know how can I change this "type" from string to number in elasticsearch/kibana?

You need to change elasticsearch mapping and force using numbers for some fields.

If possible change also your source document. And provide values as numbers instead of strings.

You can do that on your client side or use ingest feature for that.

Hi @dadoonet ,
It is hard to change my source document, hence i was preferring to change Index field's data type.
I was referring to document : https://www.elastic.co/guide/en/elasticsearch/reference/current/number.html

But it couldnt help me changing data type from string to number.
Can you suggest any reference document for this? I will try to follow! It will be great help!

Thanks!

Just a note. Changing the mapping does not alter the source. The source is always stored as you send it.

If you can't make it work provide a full recreation script as described in About the Elasticsearch category. It will help to better understand what you are doing. Please, try to keep the example as simple as possible.

A full reproduction script will help readers to understand, reproduce and if needed fix your problem. It will also most likely help to get a faster answer.

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