You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@lucenenet.apache.org by Ben Foster <be...@planetcloud.co.uk> on 2011/04/07 11:01:23 UTC

[Lucene.Net] escaping single quotes when using query parser

Hi,

 

How should we escape single quotes when working with the query parser?

 

Currently we have a description field that may contain single quotes.

 

Whilst this field is correctly indexed when we search the description no
results are returned. I'm assuming it's because we need to replace the
single quote in the search term with an escaped version.

 

Many thanks,

 

Ben Foster

 

planetcloud
The Elms, Hawton
Newark-on-Trent
Nottinghamshire
NG24 3RL

 

 <http://www.planetcloud.co.uk/> www.planetcloud.co.uk

 


Re: [Lucene.Net] escaping single quotes when using query parser

Posted by Christopher Currens <cu...@gmail.com>.
I'm not sure you're issue is related to single quotes.  The only characters
that need to be escaped for the QueryParser are + - ! ( ) { } [ ] ^ " ~ * ?
: \  You can do that using QueryParser.Escape(string).  It's possible you it
might be related to the analyzer that you're using.  In my experience,
sometimes using a different analyzer to index than you use to search can
*sometimes* cause unexpected behavior like this.  Since I haven't myself run
into this exact problem to the best of my knowledge, it's tough for me to
give a more specific answer without your code/test data.

Thanks,
Christopher

On Thu, Apr 7, 2011 at 2:01 AM, Ben Foster <be...@planetcloud.co.uk> wrote:

> Hi,
>
>
>
> How should we escape single quotes when working with the query parser?
>
>
>
> Currently we have a description field that may contain single quotes.
>
>
>
> Whilst this field is correctly indexed when we search the description no
> results are returned. I'm assuming it's because we need to replace the
> single quote in the search term with an escaped version.
>
>
>
> Many thanks,
>
>
>
> Ben Foster
>
>
>
> planetcloud
> The Elms, Hawton
> Newark-on-Trent
> Nottinghamshire
> NG24 3RL
>
>
>
>  <http://www.planetcloud.co.uk/> www.planetcloud.co.uk
>
>
>
>