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 Eun Yong Kang <ek...@cs.utah.edu> on 2006/12/20 09:39:58 UTC

giving different boost to different terms in a same document

Hi,

I am trying to figure out how to give different weights to different 
terms in a same document.
Anybody knows how to do this?

For example,

doc A   contains  field1 : term1  (weight C)   field1 : term2 (weight F)

If I use setBoost(float)  function in the Field Object, I cannot give 
different weight to
term1 and term2.

Thanks,

Eun

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


RE: giving different boost to different terms in a same document

Posted by Michael Rusch <mc...@facstaff.wisc.edu>.
It's definitely my understanding that this is not possible.  Maybe somebody
can give you a hardcore way of doing it by subclassing one of the classes
involved in indexing, but I'm too green for that :)

One solution that may or may not work depending on how specific you want to
get is that you can put the more highly boosted terms in separate fields,
and use field boosts.  Then, the magic you have to apply would be at query
time where you make sure that user's queries automatically get turned into
queries on all of the fields.

This is something that we are doing already, except it's only implemented in
my head...so it's more of a brainstorm than a proven technique...

Michael.

> -----Original Message-----
> From: Eun Yong Kang [mailto:ekang@cs.utah.edu]
> Sent: Wednesday, December 20, 2006 12:33 PM
> To: java-user@lucene.apache.org
> Subject: Re: giving different boost to different terms in a same document
> 
> 
> Yes I want to do boost in indexing time.
> But I want to do boost for terms instead of fields. I want to give
> different weight for
> different terms even if the field of two terms are same.
> 
> For example,
> 
> doc A   contains  field1 : term1  (weight C)   field1 : term2 (weight F)
> 
> I want to give different boost factor for term1 and term2, even if term1
> and term2  are
> in the same field (field1).
> 
> Anybody knows how to do this?
> 
> Eun
> 
> 
> Erick Erickson wrote:
> > I don't think you want to do this at index time, but rather search time.
> > Quoting from Hoss (?)...
> >
> > Index time field boosts are a way to express things like "this documents
> > title is worth twice as much as the title of most documents". Query time
> > boosts are a way to express "I care about matches on this clause of my
> > query
> > twice as much as I do about matches to other clauses of my query".
> >
> > From your example, it looks like you want query time boosts rather than
> > index time boosts....
> >
> > Erick
> >
> > On 12/20/06, Eun Yong Kang <ek...@cs.utah.edu> wrote:
> >>
> >> Hi,
> >>
> >> I am trying to figure out how to give different weights to different
> >> terms in a same document.
> >> Anybody knows how to do this?
> >>
> >> For example,
> >>
> >> doc A   contains  field1 : term1  (weight C)   field1 : term2 (weight
> F)
> >>
> >> If I use setBoost(float)  function in the Field Object, I cannot give
> >> different weight to
> >> term1 and term2.
> >>
> >> Thanks,
> >>
> >> Eun
> >>
> >> ---------------------------------------------------------------------
> >> To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
> >> For additional commands, e-mail: java-user-help@lucene.apache.org
> >>
> >>
> >
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
> For additional commands, e-mail: java-user-help@lucene.apache.org



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


Re: giving different boost to different terms in a same document

Posted by Eun Yong Kang <ek...@cs.utah.edu>.
Yes I want to do boost in indexing time.
But I want to do boost for terms instead of fields. I want to give 
different weight for
different terms even if the field of two terms are same.

For example,

doc A   contains  field1 : term1  (weight C)   field1 : term2 (weight F)

I want to give different boost factor for term1 and term2, even if term1 
and term2  are
in the same field (field1).

Anybody knows how to do this?

Eun


Erick Erickson wrote:
> I don't think you want to do this at index time, but rather search time.
> Quoting from Hoss (?)...
>
> Index time field boosts are a way to express things like "this documents
> title is worth twice as much as the title of most documents". Query time
> boosts are a way to express "I care about matches on this clause of my 
> query
> twice as much as I do about matches to other clauses of my query".
>
> From your example, it looks like you want query time boosts rather than
> index time boosts....
>
> Erick
>
> On 12/20/06, Eun Yong Kang <ek...@cs.utah.edu> wrote:
>>
>> Hi,
>>
>> I am trying to figure out how to give different weights to different
>> terms in a same document.
>> Anybody knows how to do this?
>>
>> For example,
>>
>> doc A   contains  field1 : term1  (weight C)   field1 : term2 (weight F)
>>
>> If I use setBoost(float)  function in the Field Object, I cannot give
>> different weight to
>> term1 and term2.
>>
>> Thanks,
>>
>> Eun
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
>> For additional commands, e-mail: java-user-help@lucene.apache.org
>>
>>
>


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


Re: giving different boost to different terms in a same document

Posted by Erick Erickson <er...@gmail.com>.
I don't think you want to do this at index time, but rather search time.
Quoting from Hoss (?)...

Index time field boosts are a way to express things like "this documents
title is worth twice as much as the title of most documents". Query time
boosts are a way to express "I care about matches on this clause of my query
twice as much as I do about matches to other clauses of my query".

>From your example, it looks like you want query time boosts rather than
index time boosts....

Erick

On 12/20/06, Eun Yong Kang <ek...@cs.utah.edu> wrote:
>
> Hi,
>
> I am trying to figure out how to give different weights to different
> terms in a same document.
> Anybody knows how to do this?
>
> For example,
>
> doc A   contains  field1 : term1  (weight C)   field1 : term2 (weight F)
>
> If I use setBoost(float)  function in the Field Object, I cannot give
> different weight to
> term1 and term2.
>
> Thanks,
>
> Eun
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
> For additional commands, e-mail: java-user-help@lucene.apache.org
>
>