Type of Long not valid in time series dimension

Hi
Is this a bug? I can't use a type long field for a time_series_dimension. this is a simple example:

PUT /temperature01
{
    "settings": {
        "index": {
            "mode": "time_series",
            "time_series": {
                "start_time": "2023-01-01T00:00:00Z",
                "end_time": "2023-01-03T23:59:59Z"
            },
            "routing_path": [
                "thermometer.id"
            ],
            "number_of_replicas": 0,
            "number_of_shards": 1
        }
    },
    "mappings": {
        "properties": {
            "@timestamp": {
                "type": "date"
            },
            "thermometer": {
                "properties": {
                    "id": {
                        "type": "long",
                        "time_series_dimension": true
                    },
                    "value": {
                        "type": "long",
                        "time_series_metric": "gauge"
                    }
                }
            }
        }
    }
}

If I change it to keyword the thermometer.id then it works, but in the documentation it says it should accept type Long

I just tried it and it accepted the mapping, are you getting some kind of error there?

sorry made a typo on on the script, "themometer.id" should be "thermometer.id". I updated it in my post
So the error I get is this

{
  "error": {
    "root_cause": [
      {
        "type": "illegal_argument_exception",
        "reason": "All fields that match routing_path must be keywords with [time_series_dimension: true] and without the [script] parameter. [thermometer.id] was [long]."
      }
    ],
    "type": "illegal_argument_exception",
    "reason": "All fields that match routing_path must be keywords with [time_series_dimension: true] and without the [script] parameter. [thermometer.id] was [long]."
  },
  "status": 400
}

Thanks for raising this. This is a current limitation, a routing field need to be a keyword field.
I'm not sure whether this limitation can be lifted. But it makes sense to me to open an issue for this.

I've opened this issue: Allow number fields as routing fields? · Issue #95069 · elastic/elasticsearch · GitHub
Note that this limitation is documented: Time series data stream (TSDS) | Elasticsearch Guide [8.7] | Elastic

1 Like

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