Question

My application takes a user inputted string and tries to parse it with the Lucene query parser. I noticed however that there are several formats of strings that provoke an error in this query parser.
e.g.:

  • ~anystring
  • anystring +

First I tried molding my user inputted string so that it could not contain these cases, but as I see it, there could be more cases I do not foresee now.

How do you handle Query parser exceptions? How do you prevent them?

Was it helpful?

Solution

We catch the remaining parse exceptions and display an error message ("Your search did not match any documents. Suggestion: Try different keywords.").

See also How to make the Lucene QueryParser more forgiving?

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top