Hi there, (sorry for all the questions.. for those regular peeps that keep seeing me pop up )
I have a requirement to sort the results returned by ElasticSearch by a special value i define, let's call it 'X'.
Now - the problem is, 'X' is a value derived based on:
- field A in the document (which is a 'term')
- field B (which is a 'date')
- the current date (UTC)
So, the problem is obviously 3. The date always changes, therefore i'm not sure how to include this in the sort, since it's not part of the document.
Do i need to use a 'script' here? Will that perform well?
The only other idea that came to mind is to calculate the value nightly, and store that in each document. But that has a few drawbacks:
- i need to have something running in the background to update this value
- could be a lot of documents to update (60%+ every night).
- i lose precision for the value depending on how long between script runs. (if i run nightly, value is 23 hours 'stale')