hi all!
i am getting some very strange behavior while using scripted sorting.
the script itself looks approximately like that:
if (doc['fieldName1'].size() != 0 && doc['fieldName2'].size() != 0) { // 1 - might not be true, so a fallback scenario is added
long field1 = doc['fieldName1'].value;
double field2 = doc['fieldName2'].value;
if (field1 == 2) {
return field1 * params.paramValueName / field2
} else {
return field2 * params.paramValueName / field1
}
} else {
if (doc['fallBackField'].size() != 0) { // 2 - always true, checked for emptiness out of safety reasons
return doc['fallbackField'].value;
} else {
return 1; // least possible case
}
};
each time a script is run, it ends in an arm 2 where the fallback scenario returns the value of a fallback field.
but when i query the index manually via curl by the known id, i can see that the values checked in the first if are always filled.
curl -X GET "localhost:9200/indexName_v46/_search?pretty" -H 'Content-Type: application/json' -d '
{ "query": { "bool": { "must" : [ { "match" : { "_id": "51c370c8-7a60-4b15-9466-0692e6b01e86" } } ] } }, "_source": [ "fieldName1", "fieldName2" ] }'
what might be the issue i receive null values on each call and fall into a fallback case?