What you want to do is:
- Know if the date is in the future or the past
- Use different boost functions for each case
Assuming the field name is due_date, we'll start building your query.
First, you want to get the time difference.
&timediff=ms(due_date,NOW)
You can use NOW/HOUR, NOW/DAY for better performance
Second, we need to know if duration is positive or negative: adding a number to its absolute value will return 1/true on positive and 0/false on negative.
&future=sum($timediff,abs($timediff)
Now depending whether the number is positive or negative you want to apply different boost functions. You can use any function you want here.
&futureboost=recip($timediff,1,36000000,36000000)
&pastboost=recip($timediff,1,3600000,3600000)
$finalboost=if($future,$futureboost,$pastboost)
&boost=$finalboost
Notice that futureboost parameters are 10x more than pastboost which will give higher boost to future documents than past ones. The recip function is documented on the Solr Function Query page and you can tune the parameters of both futureboost and pastboost functions to your case.
To return the function value, you can use:
&fl=_DATE_BOOST_:$finalboost
Full Query will be a combination of all the above:
&timediff=ms(due_date,NOW/HOUR)
&future=sum($timediff,abs($timediff)
&futureboost=recip($timediff,1,36000000,36000000)
&pastboost=recip($timediff,1,3600000,3600000)
$finalboost=if($future,$futureboost,$pastboost)
&boost=$finalboost
&fl=_DATE_BOOST_:$finalboost