lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Mike Klaas <mike.kl...@gmail.com>
Subject Re: Custom query parser
Date Thu, 22 Nov 2007 21:48:55 GMT
On 22-Nov-07, at 8:49 AM, Nicolas Lalevée wrote:

> Le jeudi 22 novembre 2007, Matthijs Bierman a écrit :
>> Hi Nicolas,
>>
>> Why can't you extend the QueryParser and override the methods you  
>> want
>> to modify?
>
> Because the query parser I would like to have is a very basic user  
> one, ala
> google. The syntax I would like is nothing more than :
> "type:text OR foo -bar"
> I also don't want the user to be popuped with parsing error, and  
> further more,
> even with errors, I don't want to drop the failing terms. A search
> for "bla:foo:bar" should fallback to "bla foo bar".

This is usually best handled by preprocessing the query and  
validating it yourself.

> So I have the parser, but it seems, unless I have missed something,  
> that I
> have to reimplement (copy and paste) the QueryParser#getFieldQuery

You could override it, call the super method, then if the resulting  
query is a PhraseQuery, extract the components and replace the query  
with a span query of prefix queries, or somesuch.

-Mike
---------------------------------------------------------------------
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