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 Sagar Khetkade <sa...@hotmail.com> on 2009/04/11 06:43:04 UTC

special characters in Solr search query.

Hi,
 
There is a strange issue while querying on the Solr indexes. If my query contains the special characters like [ ] !<> etc. It is throwing the query parse exception. From my application interface I am able to handle the special characters but the issue is while the document which I am going to index contains any of these special characters it is throwing query parse exception. Can anyone give pointer over this? 
Thanks in advance.
 
Regards,
Sagar Khetkade

_________________________________________________________________
The new Windows Live Messenger. You don’t want to miss this.
http://www.microsoft.com/india/windows/windowslive/messenger.aspx

Re: special characters in Solr search query.

Posted by Chris Hostetter <ho...@fucit.org>.
: the special characters but the issue is while the document which I am 
: going to index contains any of these special characters it is throwing 
: query parse exception. Can anyone give pointer over this? Thanks in 

your question is kind of vauge ... for instance: it seems like you are 
saying that you get query parse exceptions when you try to *index* a 
document containing one of these characters ... which would be really odd.

can you give some specifics about what exactly it is you are doing? ... 
either the literal Solr URLs that you are GETing manually, or the Code 
that you are using to talk to solr?

-Hoss


Re: special characters in Solr search query.

Posted by Shalin Shekhar Mangar <sh...@gmail.com>.
On Sat, Apr 11, 2009 at 10:13 AM, Sagar Khetkade <sagar.khetkade@hotmail.com
> wrote:

>
> There is a strange issue while querying on the Solr indexes. If my query
> contains the special characters like [ ] !<> etc. It is throwing the query
> parse exception. From my application interface I am able to handle the
> special characters but the issue is while the document which I am going to
> index contains any of these special characters it is throwing query parse
> exception. Can anyone give pointer over this?
> Thanks in advance.
>

You need to escape those characters. Look at
http://lucene.apache.org/java/2_4_1/queryparsersyntax.html#Escaping%20Special%20Characters

If you are using Solrj, this should be done automatically. Solrj calls
ClientUtils.escapeQueryChars under the hood.
-- 
Regards,
Shalin Shekhar Mangar.