I want to do sum aggregation of a salary which is stored as String in document. I dont want to convert the string value to int in database itself. Something like below in mongoDB using java driver.
SELECT sum(CAST(amount AS UNSIGNED)) FROM tbl1
I tried to cast in acumulator as follows but its giving zero as output.
accumulator = Accumulators.sum("value", $toInt: "$"+field);
I can do it in native mongodb query but I want to do it in java driver.