I'm using zope 2.7.5 and when doing a catalog search in a ZCTextIndex
containing the starting with the word "and" it barfs with this errror:
E.g. http://www.peterbe.com/search?q=and+i+cant+stop+thinking+about+you

Error Type: ParseError
Error Value: Token 'ATOM' required, 'and' found
(traceback below)

It works perfectly fine with 
http://www.peterbe.com/search?q=i+and+cant+stop+thinking+about+you
because then it doesn't start with "and".

The easy fix is so do something like this:
  if q.lower().startswith('and'):
      q= q[3:]
  results = self.Catalog.searchResults(title=q)

But, is there a more robust solution to this? One that doesn't require
hardcoded English words in the code. Is there a way to escape "and"
and "or" to treat them as actual words?



Traceback (innermost last):
  Module ZPublisher.Publish, line 101, in publish
  Module ZPublisher.mapply, line 88, in mapply
  Module ZPublisher.Publish, line 39, in call_object
  Module Products.Peterbecom.Homepage, line 967, in SearchCatalog
  Module Products.Peterbecom.Homepage, line 985, in getSearchResults
  Module Products.ZCatalog.ZCatalog, line 649, in searchResults
  Module Products.ZCatalog.Catalog, line 753, in searchResults
  Module Products.ZCatalog.Catalog, line 496, in search
  Module Products.ZCTextIndex.ZCTextIndex, line 198, in _apply_index
  Module Products.ZCTextIndex.QueryParser, line 123, in parseQuery
  Module Products.ZCTextIndex.QueryParser, line 163, in _parseOrExpr
  Module Products.ZCTextIndex.QueryParser, line 176, in _parseAndExpr
  Module Products.ZCTextIndex.QueryParser, line 211, in _parseTerm
  Module Products.ZCTextIndex.QueryParser, line 230, in _parseAtom
  Module Products.ZCTextIndex.QueryParser, line 158, in _get
  Module Products.ZCTextIndex.QueryParser, line 144, in _require
ParseError: Token 'ATOM' required, 'and' found


-- 
Peter Bengtsson, 
work www.fry-it.com
home www.peterbe.com
hobby www.issuetrackerproduct.com
_______________________________________________
Zope maillist  -  Zope@zope.org
http://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists -
 http://mail.zope.org/mailman/listinfo/zope-announce
 http://mail.zope.org/mailman/listinfo/zope-dev )

Reply via email to