1
votes

I have a more like this query which I would like to update to return newer documents first. According to the documentation, I would need to add recip(ms(NOW,mydatefield),3.16e-11,1,1) to my query.

But when I try to add it to either of mlt.qf or bf parameters. The results stay exactly the same.

This is my query:

/solr/mlt?

q=id:cms.article.137861

&defType=edismax

&rows=3

&indent=on

&mlt.fl=series_id,tags,title,text

&mlt.qf=show_id text^1.1 title^1.1 tags^90

&wt=json

&fl=url,title,tags,django_id,content_type_id

&bf=recip(ms(NOW,pub_date),3.16e-11,1,1)

2

2 Answers

1
votes

this is taken from the solr wiki (its down but i have it cached) i think this is what you are looking for.

How can I boost the score of newer documents

Do an explicit sort by date (relevancy scores are ignored) Use an index-time boost that is larger for newer documents Use a FunctionQuery to influence the score based on a date field. In Solr 1.3, use something of the form recip(rord(myfield),1,1000,1000) In Solr 1.4, use something of the form recip(ms(NOW,mydatefield),3.16e-11,1,1) http://lucene.apache.org/solr/api/org/apache/solr/search/function/ReciprocalFloatFunction.html http://lucene.apache.org/solr/api/org/apache/solr/search/BoostQParserPlugin.html A full example of a query for "ipod" with the score boosted higher the newer the product is:

http://localhost:8983/solr/select?q={!boost b=recip(ms(NOW,manufacturedate_dt),3.16e-11,1,1)}ipod One can simplify the implementation by decomposing the query into multiple arguments:

http://localhost:8983/solr/select?q={!boost b=$dateboost v=$qq}&dateboost=recip(ms(NOW,manufacturedate_dt),3.16e-11,1,1)&qq=ipod Now the main "q" argument as well as the "dateboost" argument may be specified as defaults in a search handler in solrconfig.xml, and clients would only need to pass "qq", the user query.

To boost another query type such as a dismax query, the value of the boost query is a full sub-query and hence can use the {!querytype} syntax. Alternately, the defType param can be used in the boost local params to set the default type to dismax. The other dismax parameters may be set as top level parameters.

http://localhost:8983/solr/select?q={!boost b=$dateboost v=$qq defType=dismax}&dateboost=recip(ms(NOW,manufacturedate_dt),3.16e-11,1,1)&qf=text&pf=text&qq=ipod Consider using reduced precision to prevent excessive memory consumption. You would instead use recip(ms(NOW/HOUR,mydatefield),3.16e-11,1,1). See this thread for more information.

0
votes

apparently your date field is not a TrieDate