lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Doug Cutting <cutt...@lucene.com>
Subject Re: Fields with same name but different boosts
Date Mon, 24 Nov 2003 21:12:50 GMT
Andrzej Bialecki wrote:
> Now, I'm wondering how do I encode the weight of keywords... If I do the 
> following:
> 
> Field f = Field.Keyword("kw", "value1");
> f.setBoost(10.0);
> doc.add(f);
> f = Field.Keyword("kw", "value2");
> f.setBoost(20.0);
> doc.add(f);
> 
> Now the question is: what is the boost value for the fields when I 
> search? Is it equivalent to "value1^10.0 value2^20.0" (which is my 
> intention), or rather "value1^20.0 value2^20.0"?

I think the boost will be 200.0.  Boosts are multiplicative.

> If the latter, do you have any suggestions how to achieve the original 
> effect?

The only way to do this is to repeat occurences of each word.

So you might:

   for (int i = 0; i < 10; i++) {
     doc.add(new Field("kw", "value1", false, true, false);
   }

   for (int i = 0; i < 20; i++) {
     doc.add(new Field("kw", "value1", false, true, false);
   }

You might also consider using a custom Similarity implementation so that 
you can control the interpretation of these frequencies.  For example, 
you might, instead of 10 and 20, be able to just use 1 and 2 and then, 
in your Similarity.tf() implementation, turn this into whatever value 
you want used in the scoring.

Doug


---------------------------------------------------------------------
To unsubscribe, e-mail: lucene-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: lucene-user-help@jakarta.apache.org


Mime
View raw message