"Chun Wei Ho" <[EMAIL PROTECTED]> wrote on 20/03/2006 11:09:38 AM: > I am wondering if anyone has existing code for a simpler QueryParser - > one that does not create the more complex prefix/fuzzy/range queries, > but still allow the usual term/boolean queries. > > I use QueryParser to directly parse user input (allowing for more > flexible specification of include/exclude and fields conditions), but > do not want them to use the more resource intensive queries. > > Just checking since QueryParser is done in javacc which I have little > experience in to rewrite or subclass.
The "Lucene In Action" book has a section about exactly this issue: section 6.3.2, "Prohibiting fuzzy and wildcard queries". The idea is that you can tell the existing QueryParser not to allow such queries, rather than write a different parser. The trick is to create a new class, say, LimitedQueryParser, extending QueryParser, and override it's getWildCardQuery, getFuzzyQuery, getRangeQuery (see the QueryParser documentation for the full list); If you don't want any of these supported, just throw an exception (typically ParseException), and the parsing will fail if these features are used (or, alternatively, think of what else you can do in this case). -- Nadav Har'El --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]