Hi  Tom,
I have the similar requirement, and  have found a way ..
TermQury is an atom query,other queries like boolean query  will be spitted 
into  term queries rang query etc.You can customize your own TermScorer, add a 
new "IndexReader" object  in TermScorer, and retrieve the field value of the 
doc through this IndexReader object. then you can change the score of the doc 
based on the field value. The score changing process can be implemented in 
method "protected boolean score(HitCollector c, int end) ".

One problem is that if  there are many hits meet your search query, you have 
too retrieve the field info of all the documents that match your query,this is 
very inefficient. 

I also want to know whether there are any better solutions ?

Thanks
-chee
  


----- Original Message ----- 
From: "Tom Emerson" <[EMAIL PROTECTED]>
To: <java-user@lucene.apache.org>
Sent: Saturday, December 08, 2007 5:03 AM
Subject: Re: Boosting hits based on a value in a field, without that field 
contributing to the search


> Hi Grant,
> 
> I was thinking that something in o.a.l.search.function was going to be the
> route to take, but wanted to hear if there were other ideas from the
> experts. Thanks!
> 
> A custom sort wouldn't work in this case because we don't want the items to
> necessarily be bunched together, rather just have their scores increased.
> 
> Thanks again.
> 
>    -tree
> 
> On Dec 7, 2007 3:26 PM, Grant Ingersoll <[EMAIL PROTECTED]> wrote:
> 
>> Have a look at the o.a.l.search.function package, which can be used to
>> give boosts to documents based on the value contained in a field.
>> Also, would a custom sort work?
>>
>> -Grant
>>
>> On Dec 7, 2007, at 1:42 PM, Tom Emerson wrote:
>>
>> > Hello,
>> >
>> > I'm looking for suggestions on how to deal with the following
>> > (simplified)
>> > scenario (Lucene 2.2.0):
>> >
>> > Documents in my index have some number of fields that are searched in
>> > various combinations via boolean queries.
>> >
>> > Each document also contains a field that contains a field that isn't
>> > searched that contains values "Foo", "Bar", "Baz", or no value at all.
>> >
>> > I need to boost the score of a hit in a Document by different
>> > amounts based
>> > on whether the field in the matching document contains "Foo", "Bar",
>> > or
>> > "Baz".
>> >
>> > Heretofore I have been adding a document boost at indexing time
>> > based on the
>> > source data that is being indexed in each document. This makes the
>> > boost
>> > apply across the board and gives the desired results. However, my
>> > users now
>> > want to the ability to selectively apply the boost or not, so doing
>> > this at
>> > indexing time is no longer an option.
>> >
>> > Many thanks in advance for your thoughts,
>> >
>> >    -tree
>> >
>> > --
>> > Tom Emerson
>> > [EMAIL PROTECTED]
>> > http://www.dreamersrealm.net/~tree<http://www.dreamersrealm.net/%7Etree>
>>
>> --------------------------
>> Grant Ingersoll
>> http://lucene.grantingersoll.com
>>
>> Lucene Helpful Hints:
>> http://wiki.apache.org/lucene-java/BasicsOfPerformance
>> http://wiki.apache.org/lucene-java/LuceneFAQ
>>
>>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: [EMAIL PROTECTED]
>> For additional commands, e-mail: [EMAIL PROTECTED]
>>
>>
> 
> 
> -- 
> Tom Emerson
> [EMAIL PROTECTED]
> http://www.dreamersrealm.net/~tree
>

Reply via email to