I'm using Solr to search inside a catalogue of many items (around 3
All of these items have a field containing the date they were created
(it's a string field at the moment, as i have this type inside my DB).
I want to give a higher score to the ones with the most recent date, but i
up with something like this (at query time):
[...] AND (publ_date:[2007-00-00 TO 2007-12-31]^3.0 |
publ_date:[2006-00-00 TO 2006-12-31]^2.6 |
publ_date:[2005-00-00 TO 2005-12-31]^2.3 |
publ_date:[2004-00-00 TO 2004-12-31]^2.0 |
publ_date:[2003-00-00 TO 2003-12-31]^1.6 |
publ_date:[2002-00-00 TO 2002-12-31]^1.3 |
publ_date:[2001-00-00 TO 2001-12-31]^1.0 |
publ_date:[2000-00-00 TO 2000-12-31]^0.6 |
publ_date:[1990-00-00 TO 1999-12-31]^0.3 |
publ_date:[0000-00-00 TO 2010-12-31]) [...]
It doesn't look like the best solution available to me though.
Any suggestions in how i can implement this differently ?
> ...All of these items have a field containing the date they were created
> (it's a string field at the moment, as i have this type inside my DB).
> I want to give a higher score to the ones with the most recent date...
What you think about Andrej's idea (copy/pasted here)?
"Add a separate field, say "days", in which you will put as many "1" as
many days elapsed since the epoch (not neccessarily since 1 Jan 1970 -
pick a date that makes sense for you). Then, if you want to prioritize
newer documents, just add "+days:1" to your query. Voila - the final
results are a sum of other score factors plus a score factor that is
higher for more recent document, containing more 1-s"
I'm just wondering if this way may boost the date field too much
compared to the other fields?