Question

I'm using Solr 4.0 with solnet. I'm facing issue with filter while filter name contains contains "(" and ")" .

e.g Filter name is "Test (test) Test2". I got an error while filtering with this type of filter.

Error is The remote server returned an error: (400) Bad Request.

How to handle this type of situation? Is there any other way?

Was it helpful?

Solution

Lucene supports escaping special characters that are part of the query syntax. The current list special characters are

    • && || ! ( ) { } [ ] ^ " ~ * ? : \

To escape these character use the \ before the character. For example to search for (1+1):2 use the query:

\(1\+1\)\:2

Source -

http://lucene.apache.org/core/2_9_4/queryparsersyntax.html#Escaping Special Characters

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