On Wed, Aug 11, 2010 at 10:20, Benjamin Brown
<[email protected]> wrote:
> -----Original Message-----
> From: Alexander Klimetschek [mailto:[email protected]]
> Sent: 10 August 2010 23:46
> To: [email protected]
> Subject: Re: Double String escaping - is it needed?
>
>> Generally the escaping is necessary to differentiate between actually
>> looking for that literal including a special character (which mostly
>> isn't available in the full-text index anyway) or having those special
>> characters be used as part of the lucene search syntax.
>
> Thanks for the clarification - it's helped separate my understanding of the 
> problem.
>
> I don't actually need to have the special lucene characters as I'll be adding 
> fields in future such as "Must not include" etc. for which we'll substitute 
> the lucene characters on behalf of the user.
>
> What this means is that the method I provided in the last post (but now using 
> another method name) is only suitable for our particular case as it provides 
> for our requirements of escaping the last character (side effect - by way of 
> escaping lucene characters), escaping the lucene characters, and removing 
> single quotes.

Yes. What you always want to do is avoid invalid (lucene) query
exceptions, since they give you no result at all. This is what an odd
number of double-quotes will produce (where my method helps) or the
special lucene characters at the end of the string (where
Text.escapeIllegalXpathSearchChars() helps).

Regards,
Alex

-- 
Alexander Klimetschek
[email protected]

Reply via email to