Change field types from String to integers and floats

I have the following data in elasticsearch. The system, which I cannot change, is putting most fields in as strings. See for example MaxProcessingTime. I want to use this data to graph it. The line graphs though need the data to be numeric fields! Can I change a type from a String to either a integer or float?

{
  "_index": "insight-2017.03.30",
  "_type": "sta-camel",
  "_id": "38MDo7Z_T_O1-bJTfnZCbw",
  "_score": 1,
  "_source": {
    "host": "myMetric",
    "@timestamp": "2017-03-30T16:02:10.780+01",
    "log-example-context": {
      "routes": {
        "log-route": {
          "ExchangesCompleted": "527",
          "MeanProcessingTime": "2",
          "ExchangesFailed": "0",
          "TotalProcessingTime": "1409",
          "FailuresHandled": "0",
          "MaxProcessingTime": "253",
          "Load15": "0.0",
          "Load05": "0.0",
          "ExternalRedeliveries": "0",
          "InflightExchanges": "0",
          "MinProcessingTime": "0",
          "Redeliveries": "0",
          "ExchangesTotal": "527",
          "Load01": "0.0"
        }
      }
    }
  }
}

Please format your code using </> icon as explained in this guide. It will make your post more readable.

Or use markdown style like:

```
CODE
```

You need to reindex to change the type of any existing field.

I have just tried the following to change the type of a field named 'ExchangesCompleted' and although I got a acknowledged=true back the data it is still a string. Note that the property is nested and not sure if the syntax is correct.

curl -XPUT 'http://<somehost>:9200/insight-2017.03.31/sta-camel/_mapping' -d '
{
    "sta-camel" : {
        "properties" : {
            "_source.log-example-context.routes.log-route.ExchangesCompleted" : {"type" : "integer", "store" : "yes"}
        }
    }
}
'

The following query

http://localhost:9200/insight-2017.03.31/sta-camel/_search

gives the following response

{
	"took": 10,
	"timed_out": false,
	"_shards": {
		"total": 5,
		"successful": 5,
		"failed": 0
	},
	"hits": {
		"total": 111,
		"max_score": 1.0,
		"hits": [
			{
				"_index": "insight-2017.03.31",
				"_type": "sta-camel",
				"_id": "BHK23R5uSqSvlQygG5t1wA",
				"_score": 1.0,
				"_source": {
					"host": "myMetric",
					"@timestamp": "2017-03-31T08:24:02.743+01"
				}
			},
			{
				"_index": "insight-2017.03.31",
				"_type": "sta-camel",
				"_id": "9RZH3H3RSEWlyL6N9BFOqg",
				"_score": 1.0,
				"_source": {
					"host": "myMetric",
					"@timestamp": "2017-03-31T08:33:02.967+01",
					"log-example-context": {
						"routes": {
							"log-route": {
								"ExchangesCompleted": "107",
								"MeanProcessingTime": "1",

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