lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Steven Rowe <>
Subject Re: Limiting QueryParser
Date Tue, 21 Nov 2006 23:29:50 GMT
static String QueryParser.escape(String) should do the trick:


Look at the bottom of the below-linked page for the list of characters
that the above method will escape:



Mark Miller wrote:
> if you scan the query and escape all colons (ie \:) then you should be
> good (I have not verified). Of course you will not be able to do a field
> search, but that seems to be what your after.
> Antony Bowesman wrote:
>> Hi,
>> I have a search UI that allows search criteria to be input against
>> specific fields, e.g. Subject.
>> In order to create a suitable Lucene Query, I must analyze that String
>> so that it becomes a set of Tokens which I can then turn into Terms. 
>> QueryParser seems to fit the bill for that, however, it is too clever
>> as it assumes that anything suffixes with a : is a field reference.
>> If someone enters
>> important:conference agenda
>> in the subject field, I don't want QP to translate this to
>> +important:conference +defaultfield:agenda
>> I want to end up with
>> +subject:important +subject:conference +subject:agenda
>> I've written something to do this, but I know it is not as clever as
>> QP as currently it can only create BooleanQueries with TermQueries and
>> cannot handle PhraseQuery, so would not handle
>> important:"conference agenda"
>> correctly.  Does anyone have any pointers on how to limit QueryParser
>> so that I can force it to treat what it thinks as fields as terms.
>> Thanks
>> Antony

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message