lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Erik Hatcher <e...@ehatchersolutions.com>
Subject Re: trying to boost a phrase higher than its individual words
Date Fri, 28 Oct 2005 14:38:40 GMT
On 27 Oct 2005, at 19:13, Andy Lee wrote:

> I have a situation where I want to search for individual words in a  
> phrase as well as the phrase itself.  For example, if the user  
> enters ["classical music"] (with quotes) I want to find documents  
> that contain "classical music" (the phrase) *and* the individual  
> words "classical" and "music".

So in this case a matching document must have both terms?  Or could  
it just have one or the other?  If it must have both, you could try a  
PhraseQuery with a slop of Integer.MAX_VALUE.  PhraseQuery scores  
closer matches higher.

> Of course, I could just search for the individual words and the  
> phrase would get found as a consequence.  But I want documents  
> containing the phrase to appear first in the search results, since  
> the phrase is the user's primary interest.
>
> I've constructed the following query, using boost values...
>
>     [+(content:"classical music"^5.0 content:classical^0.1  
> content:music^0.1)]
>
> ...but the boost values don't seem to affect the order of the  
> search results.
>
> Am I misunderstanding the purpose or proper usage of boosts, and if  
> so, can someone explain (at least roughly) how to achieve the  
> desired result?

But as Chris suggested - check the IndexSearcher.explain() for some  
documents you feel should be ranked higher and work from there.   
You're on the right track, but some tuning appears necessary.

     Erik


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


Mime
View raw message