i use lucene search but lucene has a bunch of special characters to escape like:
- && || ! ( ) { } [ ] ^ " ~ * ? : \
i am having problem escaping these characters because they are too many and if i use the String.replaceAll() method, i'll just end up having a really long line of code just for escaping the characters. what is the best way to do? thanks!
There is also a method called QueryParser#escape, which may be useful:
Returns a String where those characters that QueryParser expects to be escaped are escaped by a preceding \.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With