If you’re using Lucene queries then there are some special characters which do magic things. Of course you might not want any wild card / range magic going on and you’d rather the searcher could look up ] without everything blowing up.
Well, you can escape those special characters simply by passing the query through the escape method of the QueryParser.. like so
searchTerm = QueryParser.escape(searchTerm);
of course this will nobble any asterixes or similar in there, so if you do want any wildcard stuff going on, add after the escaping.