On 9/26/2018 10:39 PM, Rathor, Piyush (US - Philadelphia) wrote:
We are facing some issues in search with special characters. Can you please
help in query if the search is done using following characters:
• “&”
• AND
• (
• )
There are two ways. One is to escape them. The escaping character in
Solr is a backslash.
\&
AN\D
\(
\)
The other is to use a technique or a query parser that treats all
characters as literal. Putting information inside double quotes
sometimes works, but this also makes the query a phrase query, which
might produce incorrect results. One query parser that treats all
characters literally is the field parser:
https://lucene.apache.org/solr/guide/6_6/other-parsers.html#OtherParsers-FieldQueryParser
If you use escaping, you don't have to change your query parser, which
can completely change how your query text is interpreted. Sometimes
changing the query parser is the best option, sometimes it isn't.
URL encoding the characters as Atita suggests won't help. That's
something you have to do anyway just to get certain characters to be
successfully sent in a URL. Most Solr clients for programming languages
will do the URL encoding for you.
Thanks,
Shawn