I thought Erik's article was great. There was one unanswered brainbender I had which I was hoping was in there, but... Maybe you can add this topic to the next one, Erik?
Well, I'm not sure another article on QueryParser is warranted (yet), but I'll offer a response here....
When using the QueryParser class, the parse method will throw a TokenMgrError when there is a syntax error even as simple as a missing quote at the end of a phrase query. According to the javadoc, you should never see this class derived from Error being thrown (oops?)
You must be using the instance parse method, rather than the static one. The static one does this:
try {
QueryParser parser = new QueryParser(field, analyzer);
return parser.parse(query);
}
catch (TokenMgrError tme) {
throw new ParseException(tme.getMessage());
}But the instance parse method is declared to throw a TokenMgrError.
Why is that? I'd be happy to put that same try/catch in the instance parse method, although I want to double check (CC'ing lucene-dev on this one).
Any reason not to remove the TokenMgrError exception from the instance parse method?
Has anyone discovered a good practice for trapping syntax problems and then returning an informative message to the user on how to fix their query? I would be interested in code samples as well if you have any :)
There is the javascript piece in the sandbox that could help pre-parsing expressions for validity. Otherwise, simply displaying acceptable examples of expressions is what I'd do.
Erik
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
