lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Antony Bowesman <>
Subject Limiting QueryParser
Date Tue, 21 Nov 2006 22:26:09 GMT

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.


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

View raw message