lucene-solr-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Gonzalo Rodriguez <GRodrig...@searchtechnologies.com>
Subject RE: variaton on boosting recent documents gives exception
Date Fri, 13 Feb 2015 10:18:42 GMT
Hello Michael,

You can always change the type of your sortyear field to an int, or create an int version
of it and use copyField to populate it.

And using NOW/YEAR will round the current date to the start of the year, you can read more
about this in the Javadoc: http://lucene.apache.org/solr/4_10_3/solr-core/org/apache/solr/util/DateMathParser.html

You can test it using the example collection: http://localhost:8983/solr/collection1/select?q=*:*&boost=recip(ms(NOW/YEAR,manufacturedate_dt),3.16e-11,1,1)&fl=id,manufacturedate_dt,score,[explain]&defType=edismax
and checking the explain field for the numeric value given to NOW/YEAR vs NOW/HOUR, etc.


Gonzalo

-----Original Message-----
From: Michael Lackhoff [mailto:michael@lackhoff.de] 
Sent: Thursday, February 12, 2015 8:57 AM
To: solr-user@lucene.apache.org
Subject: variaton on boosting recent documents gives exception

Since my field to measure recency is not a date field but a string field (with only year-numbers
in it), I tried a variation on the suggested boost function for recent documents:
  recip(sub(2015,min(sortyear,2015)),1,10,10)
But this gives an exception when used in a boost or bf parameter.
I guess the reason is that all the mathematics doesn't work with a string field even if it
only contains numbers. Am I right with this guess? And if so, is there a function I can use
to change the type to something numeric? Or are there other problems with my function?

Another related question: as you can see the current year (2015) is hard coded. Is there an
easy way to get the current year within the function?
Messing around with NOW looks very complicated.

-Michael
Mime
View raw message