I have a field loaded by index as startdate which is of the type" string". I created a scripted field startdate_date to store the startdate as a "date" type;
Index field: startdate- type String
Scripted field: startdate_date - Type Date
new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(doc['startdate.keyword'].value).getTime();
Plotted a line graph,
y-axis : sum savings
x-axis: date histogram (monthly)
Filter: startdate_date (scripted field) is between
from: now-2M
to: now
However, I am getting the below error
Request to Elasticsearch failed: {"error":{"root_cause":[{"type":"class_cast_exception","reason":"class_cast_exception: Cannot apply [>] operation to types [java.lang.Long] and [java.lang.String]."}],"type":"search_phase_execution_exception","reason":"all shards failed","phase":"query","grouped":true,"failed_shards":[{"shard":0,"index":"pi-automation-rpa","node":"Cz3ydcezTK6odEqc_xe2dQ","reason":{"type":"script_exception","reason":"runtime error","script_stack":["return s.get() >= v} boolean lt(Supplier s, def v) {"," ^---- HERE"],"script":"boolean gte(Supplier s, def v) {return s.get() >= v} boolean lt(Supplier s, def v) {return s.get() < v}gte(() -> { new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(doc['startdate.keyword'].value).getTime(); }, params.gte) && lt(() -> { new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(doc['startdate.keyword'].value).getTime(); },
I am trying to display only last 6 months data. I am not sure on what is causing this. Any help is appreciated.