lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Chris Hostetter <>
Subject Re: similarity function
Date Mon, 09 Nov 2009 00:04:13 GMT

: "how do i set the score of each document result to be the score of that
: of the field that best matches the search terms"?

you'll want something like this psuedo code...

 DisjunctionMaxQuery dq = new DMQ
 foreach fieldname in list_of_fields {
    BooleanQuery bq = new BQ
    foreach word in list_of_words {
      bq.add(new TermQuery(fieldname,word),  SHOULD)

...the DisjunctioNmaxQuery will only take it's score from whichever of hte 
BooleanQueries scores highest, and the setMinSHouldMatch will ensure that 
those boolean queries will match as long as at least one of the words is 
found in that field, but the more words that match the higher the score.

then all you need to do is modify your similarity class to change the tf() 
function so that a doc doesn't get a really high score just for matching 
one word many many times.


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

View raw message