Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to search for literal '(' using portal_catalog or @@search? #1537

Closed
idgserpro opened this issue Apr 19, 2016 · 7 comments
Closed

How to search for literal '(' using portal_catalog or @@search? #1537

idgserpro opened this issue Apr 19, 2016 · 7 comments

Comments

@idgserpro
Copy link

Don't know if this is already solved in Plone 5 (we're using 4.3x) or if there's a limitation in how catalog works in this specific situation.

We have some Document objects in ZODB that have "Title - (Word)" and we need to be able to search for literal '(' in our queries. When trying to use portal_catalog, we get

ParseError: Token 'EOF' required, u'(' found

Some solutions on the internet says to quote the search, if possible using the same functions already available in some scripts of Plone in skins folder, but they don't answer how to search, literally, for '(' or ')' (we may have other symbols that have this problems).

Is it possible or do we have a limitation in the catalog? Is there a third-party package (AdvancedQuery comes to mind) that provides this functionality?

@gforcada
Copy link
Sponsor Contributor

@idgserpro have you tried to escape them? i.e \( ?

@idgserpro
Copy link
Author

Yeah, create a https://github.com/collective/minimalplone4 installation. Add a Document called (TEST) and try to search for ( or \(: nothing is shown and you get the following traceback:

2016-04-25 20:37:39 ERROR Zope.SiteErrorLog 1461627459.920.432373919937 http://localhost:8080/Plone/livesearch_reply
Traceback (innermost last):
  Module ZPublisher.Publish, line 138, in publish
  Module ZPublisher.mapply, line 77, in mapply
  Module ZPublisher.Publish, line 48, in call_object
  Module Products.CMFCore.FSPythonScript, line 127, in __call__
  Module Shared.DC.Scripts.Bindings, line 322, in __call__
  Module Shared.DC.Scripts.Bindings, line 359, in _bindAndExec
  Module Products.PythonScripts.PythonScript, line 344, in _exec
  Module script, line 76, in livesearch_reply
   - <FSPythonScript at /Plone/livesearch_reply>
   - Line 76
  Module AccessControl.ZopeGuards, line 369, in guarded_apply
  Module AccessControl.ZopeGuards, line 391, in builtin_guarded_apply
  Module Products.CMFPlone.CatalogTool, line 393, in searchResults
  Module Products.ZCatalog.ZCatalog, line 604, in searchResults
  Module Products.ZCatalog.Catalog, line 925, in searchResults
  Module Products.ZCatalog.Catalog, line 547, in search
  Module Products.ZCTextIndex.ZCTextIndex, line 217, in _apply_index
  Module Products.ZCTextIndex.QueryParser, line 139, in parseQuery
ParseError: Query contains only common words: u'\\"("*'

Don't know if this is a Plone or ZCTextIndex limitation.

@hvelarde
Copy link
Member

@idgserpro what version of Plone are you using? I just tested something similar in Plone 5.0.4 and it's working:

selection_066

@idgserpro
Copy link
Author

Indeed, my bad, I didn't said which Plone version we're using: we're at 4.3.x. We'll test with 5.0.x.

@idgserpro
Copy link
Author

@hvelarde Actually, this is not a good test. You've found the document not because of "(" in the beginning of the string, but because of "Plone" string itself (since searching for "(" is ignored).

Searching only for "(":

selecao_171

Searching for "(Plone"

selecao_172

And searching just for "P", a single string search (to show that the problem is not the size of the string itself, but with ignored characterts):

selecao_173

And, to test what @gforcada suggested, but now in Plone 5:

selecao_174

@jensens
Copy link
Sponsor Member

jensens commented May 27, 2016

This is a limitation of the index implementation. You may want to open an issue at https://github.com/zopefoundation/Products.ZCTextIndex and ask over there for details if you think this is a problem.

@idgserpro
Copy link
Author

@hvelarde a little bit late, but it worked in Plone 5 because of this https://github.com/plone/Products.CMFPlone/blob/5.1b4/Products/CMFPlone/browser/search.py#L28

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants