[Erp5-report] r21329 - in /erp5/trunk/products/ZSQLCatalog: SearchKey/ tests/
nobody at svn.erp5.org
nobody at svn.erp5.org
Wed Jun 4 23:51:20 CEST 2008
Author: kazuhiko
Date: Wed Jun 4 23:51:19 2008
New Revision: 21329
URL: http://svn.erp5.org?rev=21329&view=rev
Log:
treat 'foo bar' as the 'AND' search in fulltext search, i.e. to find
documents that contain both 'foo' and 'bar' (Bug #882).
Modified:
erp5/trunk/products/ZSQLCatalog/SearchKey/FullTextKey.py
erp5/trunk/products/ZSQLCatalog/tests/testSearchKeys.py
Modified: erp5/trunk/products/ZSQLCatalog/SearchKey/FullTextKey.py
URL: http://svn.erp5.org/erp5/trunk/products/ZSQLCatalog/SearchKey/FullTextKey.py?rev=21329&r1=21328&r2=21329&view=diff
==============================================================================
--- erp5/trunk/products/ZSQLCatalog/SearchKey/FullTextKey.py (original)
+++ erp5/trunk/products/ZSQLCatalog/SearchKey/FullTextKey.py Wed Jun 4 23:51:19 2008
@@ -27,6 +27,7 @@
##############################################################################
from SearchKey import SearchKey
+import re
SEARCH_MODE_MAPPING = {'in_boolean_mode': 'IN BOOLEAN MODE',
'with_query_expansion': 'WITH QUERY EXPANSION'}
@@ -62,8 +63,6 @@
#r'[^\+\-<>\(\)\~\*\"\s]\S*'
#r'[\x7F-\xFF\w\d][\x7F-\xFF\w\d]*'
# WORD may contain arbitrary letters and numbers without white space
- word_value = t.value
- t.value = "'%s'" % word_value
return t
def buildSQLExpression(self, key, value,
@@ -79,6 +78,9 @@
if token.type != 'WORD':
mode = SEARCH_MODE_MAPPING['in_boolean_mode']
break
+ if mode == '' and len(tokens) > 1:
+ value = ' '.join(['+%s' % x.value for x in tokens])
+ mode = SEARCH_MODE_MAPPING['in_boolean_mode']
# split (if possible) to column.key
if key.find('.') != -1:
table, column = key.split('.')
Modified: erp5/trunk/products/ZSQLCatalog/tests/testSearchKeys.py
URL: http://svn.erp5.org/erp5/trunk/products/ZSQLCatalog/tests/testSearchKeys.py?rev=21329&r1=21328&r2=21329&view=diff
==============================================================================
--- erp5/trunk/products/ZSQLCatalog/tests/testSearchKeys.py (original)
+++ erp5/trunk/products/ZSQLCatalog/tests/testSearchKeys.py Wed Jun 4 23:51:19 2008
@@ -395,6 +395,13 @@
#Boolean Mode
self.compare(FullTextKey,
'full_text.SearchableText',
+ 'john stuart mill',
+ "MATCH full_text.SearchableText AGAINST ('+john +stuart +mill' IN BOOLEAN MODE)",
+ ["MATCH full_text.SearchableText AGAINST ('+john +stuart +mill' IN BOOLEAN MODE) AS full_text_SearchableText_relevance",
+ "MATCH full_text.SearchableText AGAINST ('+john +stuart +mill' IN BOOLEAN MODE) AS SearchableText_relevance"])
+
+ self.compare(FullTextKey,
+ 'full_text.SearchableText',
'John*',
"MATCH full_text.SearchableText AGAINST ('John*' IN BOOLEAN MODE)",
["MATCH full_text.SearchableText AGAINST ('John*' IN BOOLEAN MODE) AS full_text_SearchableText_relevance",
More information about the Erp5-report
mailing list