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 Igor Chudov <ic...@gmail.com> on 2010/10/14 15:36:31 UTC

Quoting special characters?

Let's say that I submit a query for a MoreLikeThis search. The query
contains special characters, that Solr/Lucene interprets specially,
such as colon ":".

Example textual query is "Solve a proportion X:2 = 4/5 and find X".
(the context is website algebra.com).

My queries never intend those characters to be interpreted for
anything other than literal value.

As a first shot, I simply replace them with a space, but I wonder if I
would be better off, matching wise, with quoting those characters
instead of removing them?

If so how do I quote such characters?

Thanks1

i

Re: Quoting special characters?

Posted by Savvas-Andreas Moysidis <sa...@googlemail.com>.
If I understand your problem right what you probably need is to escape those
characters: http://lucene.apache.org/java/2_9_1/queryparsersyntax.html#Escaping
Special Characters

On 14 October 2010 14:36, Igor Chudov <ic...@gmail.com> wrote:

> Let's say that I submit a query for a MoreLikeThis search. The query
> contains special characters, that Solr/Lucene interprets specially,
> such as colon ":".
>
> Example textual query is "Solve a proportion X:2 = 4/5 and find X".
> (the context is website algebra.com).
>
> My queries never intend those characters to be interpreted for
> anything other than literal value.
>
> As a first shot, I simply replace them with a space, but I wonder if I
> would be better off, matching wise, with quoting those characters
> instead of removing them?
>
> If so how do I quote such characters?
>
> Thanks1
>
> i
>

Re: Quoting special characters?

Posted by Otis Gospodnetic <ot...@yahoo.com>.
Do you actually want to escape them with \ ?


Look at 
this: http://search-lucene.com/?q=escape+query+characters&fc_project=Solr

Otis----
Sematext :: http://sematext.com/ :: Solr - Lucene - Nutch
Lucene ecosystem search :: http://search-lucene.com/



----- Original Message ----
> From: Igor Chudov <ic...@gmail.com>
> To: solr-user <so...@lucene.apache.org>
> Sent: Thu, October 14, 2010 9:36:31 AM
> Subject: Quoting special characters?
> 
> Let's say that I submit a query for a MoreLikeThis search. The query
> contains  special characters, that Solr/Lucene interprets specially,
> such as colon  ":".
> 
> Example textual query is "Solve a proportion X:2 = 4/5 and find  X".
> (the context is website algebra.com).
> 
> My queries never intend  those characters to be interpreted for
> anything other than literal  value.
> 
> As a first shot, I simply replace them with a space, but I wonder  if I
> would be better off, matching wise, with quoting those  characters
> instead of removing them?
> 
> If so how do I quote such  characters?
> 
> Thanks1
> 
> i
>