On Wednesday, November 12, 2003, at 11:52 PM, Tomcat Programmer wrote:
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
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.


To unsubscribe, e-mail: lucene-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: lucene-dev-help@jakarta.apache.org

Search Discussions

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupdev @
postedNov 13, '03 at 5:20a
activeNov 13, '03 at 5:20a

1 user in discussion

Erik Hatcher: 1 post



site design / logo © 2022 Grokbase