Hi All,
I have a long field ('Powerstate') in index with values ranging between 0-1. I need to do scripted field which converts these number to string values. 0=OFF, 1=ON.
I am trying with the below script,
if (doc['PowerState'].value == 0) {
return "OFF"
} else {
return "ON"
}
Below is the scripted field added in the index,
I am trying to visualize the data with powerstate and device count as like below,
Since the powerstate value is either 0 or 1 and I want to show it as OFF or ON and I tried changing the original field to scripted field in the buckets and below is the exception showing,
:5601/bundles/vendors.bundle.js:197 RequestFailure "Possibly unhandled rejection: {"message":"Request to Elasticsearch failed: {"error":{"root_cause":[{"type":"aggregation_execution_exception","reason":"Unsupported script value [OFF], expected a number, date, or boolean"}],"type":"search_phase_execution_exception","reason":"all shards failed","phase":"query","grouped":true,"failed_shards":[{"shard":0,"index":"staticinfo-2018.11","node":"ucDfjzdORoSIjMKnvthTmw","reason":{"type":"aggregation_execution_exception","reason":"Unsupported script value [OFF], expected a number, date, or boolean"}}]},"status":500}","origError":false,"resp":{"error":{"root_cause":[{"type":"aggregation_execution_exception","reason":"Unsupported script value [OFF], expected a number, date, or boolean"}],"type":"search_phase_execution_exception","reason":"all shards failed","phase":"query","grouped":true,"failed_shards":[{"shard":0,"index":"staticinfo-2018.11","node":"ucDfjzdORoSIjMKnvthTmw","reason":{"type":"aggregation_execution_exception","reason":"Unsupported script value [OFF], expected a number, date, or boolean"}}]},"status":500}}"
Please let me know your thoughts and it would be very helpful.
Regards,
Ganeshbabu R