Getting error, "Cannot cast from [Long] to [long]" and have tried many many things to no avail.
The data to query against:
"Data": {
"Number of Components": 3,
"Number of Components Array": [
{
"Component": 1,
"Number of Foos": 0,
"Number of Foos Array": []
},
{
"Component": 2,
"Number of Foos": 0,
"Number of Foos Array": []
},
{
"Component": 3,
"Number of Foos": 1,
"Number of Foos Array": [
{
"Foo State": "Bar",
"Foo Name Text": "Boogada Boogada"
}
]
}
]
}
The "Painless" script:
boolean retVal = false;
if (doc[\"Data.Number of Components\"].value > 0){
Long[] numFoos = doc[\"Data.Number of Components Array.Number of Foos\"].values;
for (def i = 0; i < numFoos.length; i++) {
if (numFoos[i] > 0L) {
ArrayList foosArray = doc[\"Data.Number of Components Array\"][i][\"Number of Foos Array\"].value;
String fooText = foosArray[i][\"Foo Name Text\"].value;
if(fooText.compareTo(\"Boogada Boogada\") == 0){
retVal = true;
}
}
}
}
return retVal;
The error:
"caused_by": {
"type": "script_exception",
"reason": "compile error",
"script_stack": [
"... i++){if (numFoos[i] > 0L) {ArrayList foos ...",
" ^---- HERE"
],
"script": """<my code>""",
"lang": "painless",
"caused_by": {
"type": "class_cast_exception",
"reason": "Cannot cast from [Long] to [long]."
}
}