You are viewing a plain text version of this content. The canonical link for it is here.
Posted to solr-user@lucene.apache.org by zqzuk <zi...@hotmail.com> on 2008/02/19 18:07:39 UTC

escaping special chars in query

Hi, solr have reserved some special chars in building its queries, such as +
* :  and so on, thus any queries must escape these chars otherwise
exceptions will occur. I wonder where can I find a complete list of chars I
need escape in the query, and what is the encoding/decoding method (URL?) 

In my test I have found these chars have caused problems: ! ^ " * ( )  + { }
[ ] \
possibly more to add?

Thanks in advance!
-- 
View this message in context: http://www.nabble.com/escaping-special-chars-in-query-tp15562322p15562322.html
Sent from the Solr - User mailing list archive at Nabble.com.


RE: escaping special chars in query

Posted by Lance Norskog <go...@gmail.com>.
You may also use Unicode escapes: \u5555 for example. 

-----Original Message-----
From: Reece [mailto:liquidpele@gmail.com] 
Sent: Tuesday, February 19, 2008 10:04 AM
To: solr-user@lucene.apache.org
Subject: Re: escaping special chars in query

The bottom of the Lucene query syntax page:
http://lucene.apache.org/java/docs/queryparsersyntax.html

>From the page:

Escaping Special Characters
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

-Reece


On Feb 19, 2008 12:07 PM, zqzuk <zi...@hotmail.com> wrote:
>
> Hi, solr have reserved some special chars in building its queries, 
> such as +
> * :  and so on, thus any queries must escape these chars otherwise 
> exceptions will occur. I wonder where can I find a complete list of 
> chars I need escape in the query, and what is the encoding/decoding 
> method (URL?)
>
> In my test I have found these chars have caused problems: ! ^ " * ( )  
> + { } [ ] \ possibly more to add?
>
> Thanks in advance!
> --
> View this message in context: 
> http://www.nabble.com/escaping-special-chars-in-query-tp15562322p15562
> 322.html Sent from the Solr - User mailing list archive at Nabble.com.
>
>


Re: escaping special chars in query

Posted by Reece <li...@gmail.com>.
The bottom of the Lucene query syntax page:
http://lucene.apache.org/java/docs/queryparsersyntax.html

>From the page:

Escaping Special Characters
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

-Reece


On Feb 19, 2008 12:07 PM, zqzuk <zi...@hotmail.com> wrote:
>
> Hi, solr have reserved some special chars in building its queries, such as +
> * :  and so on, thus any queries must escape these chars otherwise
> exceptions will occur. I wonder where can I find a complete list of chars I
> need escape in the query, and what is the encoding/decoding method (URL?)
>
> In my test I have found these chars have caused problems: ! ^ " * ( )  + { }
> [ ] \
> possibly more to add?
>
> Thanks in advance!
> --
> View this message in context: http://www.nabble.com/escaping-special-chars-in-query-tp15562322p15562322.html
> Sent from the Solr - User mailing list archive at Nabble.com.
>
>