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: Boost in Query Parser
Date Wed, 12 Nov 2003 16:13:45 GMT
On Wednesday, November 12, 2003, at 10:53  AM, MOYSE Gilles (Cetelem) 
wrote:
> Hello.
>
> I've made a Filter which recognizes special words and return them in a
> "boosted form", in a QueryParser sense.
> For instance, when the filter receives "special_word", it returns
> "special_word^3", so as to boost it.
> The problem is that the QueryParser understands the boost syntax when 
> the
> string is given as an argument to the "parse" function, but does not 
> get it
> when it is generated by a filter in the Analyzer.
> So, when my filter transforms "special_word" to "special_filter^3", the
> QueryParser does not create a Query object with "special_word" as 
> value to
> look for and boost to 3, but with "special_word^3" to search and boost 
> to 1.
> Of course, it does not match anything.
>
> Does anyone knows a solution to that problem ? Do I have to write my 
> own
> QueryParser from the beginning or do I just have to correct 2 ot 3 
> lines of
> the original QueryParser to make it work the I'd like it to work ?

One idea is to pre-process the string before handing it to QueryParser 
and do a string replacement with the boosting (^3) added appropriately.

Writing your own QueryParser is certainly a possibility.  There is 
nothing really to "correct" with the original QueryParser in this 
regard as it is working by design and there really is no way to feed 
expressions back from the analysis back into the parsing - doesn't 
really seem like a good idea to me.  You can probably get away with 
subclassing QueryParser and overriding getFieldQuery to do what you 
want with the String passed in, and calling setBoost (rather than 
trying to inject "^3").

	Erik


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


Mime
View raw message