You are viewing a plain text version of this content. The canonical link for it is here.
Posted to solr-user@lucene.apache.org by Jan Wedding <ja...@st.ovgu.de> on 2014/02/26 13:44:41 UTC

Function Query does not work properly

Hi,

I have a small problem using function queries. According to 
http://wiki.apache.org/solr/FunctionQuery#Date_Boosting and 
http://wiki.apache.org/solr/SolrRelevancyFAQ#How_can_I_boost_the_score_of_newer_documents 
I've tried using function queries to boost newer documents over older 
ones. For my case, I have documents with dates in the future, so I tried 
to adapt the example: All dates in the future should have a boost 
multiplier of 1. Therefore, I tried using the following function, so all 
dates until 100 years in the future should get a 0 through the map 
function, and all past dates should end up being used as they are after 
the map function, resulting in a boost multiplier of 1 for all future 
dates, and all past dates having the normal values of their age 
according to the recip function:

recip(map(product(ms(NOW,date_field),3.16e-11),-100,0,0),3.16e-11,1,1)

Unfortunately, this does not seem to work - this function seems to 
return 1 for any date_field value

After that, I tried using a workaround, by emulating the recip function 
using the div and product and sum functions:
div(1,sum(product(map(product(ms(NOW,date_field),3.16e-11),-100,0,0),3.16e-11),1))

This also did not work .

Finally I checked, whether the map function returns correct values, by 
executing the map function alone, so all future days should end up 
having 0 for their score. This DID work.
map(product(ms(NOW,date_field),3.16e-11),-100,0,0)

So my question now: Am I doing something wrong or is there a bug in the 
recip function?

I am currently using Solr 4.5.1.

Thanks for your help,
Jan