Currently, prices are mapped as a long integer so that 120.00 is stored as 12000. We have some dashboards we show to clients such as their total revenue. I need to display these properly as 120.00.
I've seen that it's recommended to store prices as floating points scaled to 100. However, the lead developer doesn't want to do this as he fears floating points sometimes don't convert properly. For example, he says converting 10000 cents into dollars could yield 99.99999999997.
Any advice on getting this working would be most appreciated. Thanks in advance.
Because many documents don't have a value for "price", I got an error. I used an IF statement to fix this and when I preview the scripted field, I get the correct result.
if (doc['price'].size() > 0) {
return doc['price'].value / 100.00;
}
I understand using a scripted field uses more resources as the script runs every time a search is made or visualization refreshed. Is there any way to optimize this or reduce server load?
Apache, Apache Lucene, Apache Hadoop, Hadoop, HDFS and the yellow elephant
logo are trademarks of the
Apache Software Foundation
in the United States and/or other countries.