Commit f3154e76 authored by Kazuhiko Shiozaki's avatar Kazuhiko Shiozaki

improve FULLTEXT_BOOLEAN_DETECTOR, i.e. 'a+b' is not a boolean search, but 'a +b' is.


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@37964 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent d1297927
......@@ -36,7 +36,7 @@ from zope.interface.verify import verifyClass
from Products.ZSQLCatalog.SQLCatalog import profiler_decorator
import re
FULLTEXT_BOOLEAN_DETECTOR = re.compile(r'.*[\+\-<>\(\)\~\*]')
FULLTEXT_BOOLEAN_DETECTOR = re.compile(r'.*(^|\s)[\+\-<>\(\)\~\*]')
class FullTextKey(SearchKey):
"""
......
......@@ -508,8 +508,10 @@ class TestSQLCatalog(unittest.TestCase):
Fulltext searches must switch automatically to boolean mode if boolean
operators are found in search value.
"""
self.catalog(ReferenceQuery(ReferenceQuery(operator='match_boolean', fulltext='a+b'), operator='and'),
self.catalog(ReferenceQuery(ReferenceQuery(operator='match', fulltext='a+b'), operator='and'),
{'fulltext': 'a+b'})
self.catalog(ReferenceQuery(ReferenceQuery(operator='match_boolean', fulltext='a +b'), operator='and'),
{'fulltext': 'a +b'})
self.catalog(ReferenceQuery(ReferenceQuery( ReferenceQuery(operator='=', uid='foo'),
ReferenceQuery(operator='match_boolean', fulltext='+a b'), operator='and'
), operator='and'), {'fulltext': '+a b uid:foo'})
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment