My partial mapping is as follows (I am still using ES2.4):
"name": {
"type": "string"
},
"misc": {
"type": "object",
"dynamic": "true",
"properties": {}
}
Lets assume there is only one document in my storage, as follows
{
"name": "foobar",
"misc": {
"201804": 1,
"201805": 10,
"201806": 2,
"201807": 1,
"201808": 9,
"201809": 1,
"201810": 8,
"201811": 1,
"201812": 11
}
}
In my search query, I have groovy script, where I am trying to find the value of the key inside misc
object
dynamic_key = ....my logical calculation to find key....
//assume the calculated value of dynamic_key is "201808"
kvalue = doc['misc'][dynamic_key].value //value of kvalue should be 9 as dynamic_key="201808"
I get this error type: "no_class_def_found_error",
reason: "java/lang/Throwable"
, so the dynamic key value selection fails. If I change this line kvalue = doc['misc'][dynamic_key].value
to kvalue = doc['misc.201805].value
then it finds the value correctly.
Any idea how to achieve what I am looking for?