I ended up using System.currentTimeMillis(). Will this give me the same problem? And in that case, can you please give me an example of how you would solve it?
The problem there is that script will be executed on multiple nodes (where each shard of the index resides), each of which could have a different current time. The way to have a global and consistent time is to pass it in within the request.
{
"script_score": {
"script": {
"inline": "(0.08 / ((3.16*Math.pow(10,-11.5)) * Math.abs(params['time'] - doc['created'].date.getMillis()) + 0.05)) + 1.0",
"params": {
"time": 123456789 /* time set in the request, in millis */
}
}
}
}
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.