Quantcast

Question about Boosting Fields in a Query

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Question about Boosting Fields in a Query

sven-25
 
 
Hi folks,
 
I have a question about boosting fields in a Query.
Suppose we have documents like this in the index:
 
fieldA:String fieldB:String fieldC:Date fieldD:Number
 
And the query is like that:
 
fieldA: wordA1 wordA2 wordA3 wordA4  
fieldB: wordB1 wordB2 wordB3 wordB4
fieldC:[date1 to date2]
fieldD:[number1 to number2]
 
 
Now what I want to do is to boost certain fields, for example the fieldA
of the query should be boosted by a factor of 2.
What is the most elegant way to do that?
 
btw. boosting document fields doesnt help as different users should be
able to boost different fields....
 
 
Thanks,
Sven
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Question about Boosting Fields in a Query

Otis Gospodnetic-2
Hi Sven,

http://www.lucenebook.com/search?query=search+boost+field
(hm, I was hoping to find something better)

You can use setBoost at search time: Query class has setBoost(float)
method, which you can use if you construct queries in the code, and
QueryParser supports ^float syntax, which puts the power in the hands
of people entering queries.

Otis


--- Sven <[hidden email]> wrote:

>  
>  
> Hi folks,
>  
> I have a question about boosting fields in a Query.
> Suppose we have documents like this in the index:
>  
> fieldA:String fieldB:String fieldC:Date fieldD:Number
>  
> And the query is like that:
>  
> fieldA: wordA1 wordA2 wordA3 wordA4  
> fieldB: wordB1 wordB2 wordB3 wordB4
> fieldC:[date1 to date2]
> fieldD:[number1 to number2]
>  
>  
> Now what I want to do is to boost certain fields, for example the
> fieldA
> of the query should be boosted by a factor of 2.
> What is the most elegant way to do that?
>  
> btw. boosting document fields doesnt help as different users should
> be
> able to boost different fields....
>  
>  
> Thanks,
> Sven
>

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Question about Boosting Fields in a Query

Erik Hatcher
In reply to this post by sven-25

On Apr 27, 2005, at 11:02 AM, Sven wrote:

> Hi folks,
>
> I have a question about boosting fields in a Query.
> Suppose we have documents like this in the index:
>
> fieldA:String fieldB:String fieldC:Date fieldD:Number
>
> And the query is like that:
>
> fieldA: wordA1 wordA2 wordA3 wordA4
> fieldB: wordB1 wordB2 wordB3 wordB4
> fieldC:[date1 to date2]
> fieldD:[number1 to number2]
>
>
> Now what I want to do is to boost certain fields, for example the
> fieldA
> of the query should be boosted by a factor of 2.
> What is the most elegant way to do that?

This depends on how you're constructing the query.  If you're doing it
through the API, then call query.setBoost(2.0f) on the fieldA clause.  
If this an expression you're parsing, use "expression"^2.0 syntax.

        Erik


---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Loading...