I search for documents containing text entered by the user
It works fine if there are no special characters in searchText.
The following describes how I create my QueryParser.
//analyzer is an StandardAnalyzer() QueryParser parser = new QueryParser("Text", analyzer); parser.SetAllowLeadingWildcard(true); return parser.Parse(string.Format("*{0}*", searchText));
I get the following error if the search text contains any special character:
suppose the search text is "bed ["
Cannot parse '*bed [*': Encountered "<EOF>" at line 1, column 7.
How can I make my query analyzer not crash if there are special characters in the search text, and also I do not want to ignore special characters.
source share