You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-user@lucene.apache.org by Andrzej Bialecki <ab...@getopt.org> on 2003/11/24 11:52:14 UTC
Fields with same name but different boosts
Hello,
I have the following problem: in my application I'm trying to store set
of keywords and their weights. Since the number of keywords is variable
(and can be as high as 40) I decided to use a single field to store it.
In other words, I want to use a single field with multiple values to
store a keyword histogram of the document.
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"?
If the latter, do you have any suggestions how to achieve the original
effect?
Thanks in advance!
--
Best regards,
Andrzej Bialecki
-------------------------------------------------
Software Architect, System Integration Specialist
CEN/ISSS EC Workshop, ECIMF project chair
EU FP6 E-Commerce Expert/Evaluator
-------------------------------------------------
FreeBSD developer (http://www.freebsd.org)
---------------------------------------------------------------------
To unsubscribe, e-mail: lucene-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: lucene-user-help@jakarta.apache.org
Re: Fields with same name but different boosts
Posted by Doug Cutting <cu...@lucene.com>.
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