Jinming Zhang wrote:
Hi,

I have the following situation which needs to customize the final score
according to field value.

Suppose there are two docs in my query result, and they are ordered by
default score sort:

doc1(field1:bookA, field2:2000-01-01) -- score:0.80
doc2(field1:bookB, filed2:2009-01-01) -- score:0.70

I want "doc2" to have a higher score since it's publishing date is more
recent, while "doc1" to have a lower score:

doc2(field1:bookB, filed2:2009-01-01) -- score:0.77
doc1(field1:bookA, field2:2000-01-01) -- score:0.73

I found this scenario is different from doc.setBoost() and field.setBoost().
Is there any way to impact the score calculated for "doc1" & "doc2"
according to the value of "field2"?

Thank you in advance!

hi,

If I were you, I would store the date information as a long type
(as i know, lucene stores any date information as a long type automatically, so it should be a natural way. you can change date type to long type and vice versa very easily by using lucene's provided date apis.) and make a linear function about the date information.

The input of the function is a date information and the output is a simple float value which indicates how recent a book is. As more recent books have larger function values linearly, you can finely adjust your score by weighting the output of function according to your ranking policy.

After then, simply, modify your docs' score on the fly by using the function's output at customScore() which are mentioned at one of replies for your question by patrick o'leary.

bye.





---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscr...@lucene.apache.org
For additional commands, e-mail: java-user-h...@lucene.apache.org

Reply via email to