I have a Lucene index where every document has several fields which contain numeric values. Now I would like to sort the search result on a weighted sum of this field. For e
Implement your own similarity class and override idf(Term, Searcher) method. In this method, you can return the score as follows. if (term.field.equals("field1") {
if (term.field.equals("field1") {
score = 0.5 * Integer.parseInt(term.text());
} else if (term.field.equals("field2") {
score = 1.4 * Integer.parseInt(term.text());
} // and so on
return score;
When you execute the query, make sure it is on all the fields. That is query should look like
field1:term field2:term field3:term
The final score will also add some weights based on the query normalization. But, that will not affect the relative ranking of the documents as per the equation given by you.