lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Gustavo Comba" <>
Subject Custom ScoreDocComparator and normalized Scores
Date Tue, 20 Jun 2006 09:31:42 GMT
    I'm trying to sort the search results by a "combination" of the
"lucene score" and the value of a document field. The "combination" is
something like that:
    scoreWeight * i.score + fieldWeight * getFieldValue(i.doc)
    I expect results between 0 and scoreWeight + fieldWeight
    Until version 1.9 this use to works OK, but now Lucene doesn't
normalize the documents scores before calling
ScoreDocComparator#compare(ScoreDoc i, ScoreDoc j). I know this is
necessary when combining several indexes, but it's not our case (we have
only one index).
    I'm diggin into Lucene's source code to find a way to normalize
values before sorting the results. The solution I found requires a lot
of "custom" code, and doing 2 passes over the results, one to calculate
alll the document's scores, and then a sort using a comparator "who
knows" the maximum score value (in order to normalize values on the
fly), so I think there should be a more efficient and elegant way to do
    Any ideas? Any help will be appreciated! Thanks in advance,
        Gustavo Comba

  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message