One of the things introduced with Solr 1.4 is the ms() function for getting the number of milliseconds for a timestamp since the Unix epoch. This means that you can now write date boosts without having to resort to ord() or rord().
The best solution for boosting documents based on a field on query time (to avoid having to update the boost factor based on date as time progresses) seems to be to use the boost query type. The boost query type will pass the query on to your default query handler and let that resolve the query itself, but will provide boosts for each document based on the fields queried.
An example of how to solve this issue can be found on the SolrRelevancy part of the Solr Wiki:
This will take the number of milliseconds between NOW and the time the document was published (publishedTime is one of the fields YOU have to provide when you’re indexing, this might be “created” or something else that suits your needs) and then multiply that number with 3.16e-11, which is equal to 1 /
The Solr Wiki also contains example of how you can divide your boost query into several parts to make it easier to read.
One thought on “Boosting By Date in Solr 1.4”
There’s a useful review of computation things you can with Solr at http://www.lucidimagination.com/search/document/CDRG_ch07_7.8