[Zope-dev] Re: Escaping special characters in ZCTextIndex.QueryParser?

mustapha mustapha at headnet.dk
Tue Nov 27 14:12:34 EST 2007



Robert Casties wrote:
> Hi,
> 
> is it possible to escape parentheses in ZCTextIndex searches?

Yes

> If not, why not and how can I do a simple search in an index bypassing
> the QueryParser?

I said Yes :)

> I have an index where words can contain parentheses and I am unable to
> enter a query for these words because the QueryParser interprets all
> parentheses as search expression groupings.
>
> Enclosing the words with double quotes has not helped, neither have
> backslashes...

You have to enclose  your string with double quotes and then with single
quote. So the parser gets the double quotes with the search string
The parser does not interpret the string between double quotes.

It works for me :)
suppose you are searching for: my text (really good text) to search for

txt = '"my text (really good text) to search for"'
brains = context.portal_catalog(searchableText=text)

HTH

> Is there a way other than having to write a new ZCTextIndex?
> 
> Thanks for any insight
> 
> 	Robert
> 
> _______________________________________________
> Zope-Dev maillist  -  Zope-Dev at zope.org
> http://mail.zope.org/mailman/listinfo/zope-dev
> **  No cross posts or HTML encoding!  **
> (Related lists - 
>  http://mail.zope.org/mailman/listinfo/zope-announce
>  http://mail.zope.org/mailman/listinfo/zope )
> 



More information about the Zope-Dev mailing list