lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Chris Hostetter <>
Subject Re: Custom ScoreDocComparator and normalized Scores
Date Tue, 20 Jun 2006 19:55:00 GMT

First off: why do you need the normalized scores in your equation?  for
the purposes of comparing the calculated values in order to sort them, it
shouldn't matter if they are normalized or not.

Second: I strongly suggest you take a look at FunctionQuery ... it was
created for hte expres purpose of letting you define functions that be
applied to indexed field values of each document to affect the score....

: Date: Tue, 20 Jun 2006 11:31:42 +0200
: From: Gustavo Comba <>
: Reply-To:
: To:
: Subject: Custom ScoreDocComparator and normalized Scores
: Hi,
:     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
: this.
:     Any ideas? Any help will be appreciated! Thanks in advance,
:         Gustavo Comba


To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message