How to aggregate data with type of long and add a string after each data record?

I want to aggregate the data with the following query and add a string after each data record

GET /artikeldaten_de/_search
{
  "size": 0, 
  "aggs": {
    "leuchtenstrom": {
      "terms": {
        "field": "u_leuchtenlichtstrom",
        "size": 50,
        "script": "_value + ' lm'"
      }
    }
  }
}

I get the following error:

{
  "error": {
    "root_cause": [
      {
        "type": "class_cast_exception",
        "reason": "java.lang.String cannot be cast to java.lang.Number"
      }
    ],
    "type": "search_phase_execution_exception",
    "reason": "all shards failed",
    "phase": "query",
    "grouped": true,
    "failed_shards": [
      {
        "shard": 0,
        "index": "artikeldaten_de",
        "node": "WMEp8O05QyubRrC6N6EL-A",
        "reason": {
          "type": "class_cast_exception",
          "reason": "java.lang.String cannot be cast to java.lang.Number"
        }
      }
    ],
    "caused_by": {
      "type": "class_cast_exception",
      "reason": "java.lang.String cannot be cast to java.lang.Number",
      "caused_by": {
        "type": "class_cast_exception",
        "reason": "java.lang.String cannot be cast to java.lang.Number"
      }
    }
  },
  "status": 500
}

Is it possible to cast the values into a string? Or do I have to change the mapping for the field?

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