Commit c8fdff40 authored by Kazuhiko Shiozaki's avatar Kazuhiko Shiozaki

* implicit OR search for sphinx.

* somehow working "phrase search".
* use extended2 mode instead of extended mode.


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@38008 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 342f8a69
......@@ -138,19 +138,13 @@ class SphinxSEComparisonOperator(MonovaluedComparisonOperator):
def renderValue(self, value_list):
"""
* quote each query word explicitly to invoke phrase search for
n-gram characters.
* add ';mode=extended' to invoke extended search
TODO:
* escape double quote in query word
* respect existing double quotes in user's input
* add ';mode=extended2' to invoke extended search
"""
if isinstance(value_list, (tuple, list)):
if len(value_list) > 1:
raise ValueError, '%r: value_list must not contain more than one item. Got %r' % (self, value_list)
value_list = value_list[0]
value_list = '"'+'" "'.join(value_list.split())+'";mode=extended'
value_list = '%s;mode=extended2' % value_list
return self._renderValue(value_list)
@profiler_decorator
......
......@@ -48,14 +48,22 @@ class SphinxSEFullTextKey(SearchKey):
Special Query builder for FullText queries: merge all values having the
same operator into just one query, to save SQL server from the burden to
do multiple fulltext lookups when one would suit the purpose.
Example:
'aaa bbb' : '"aaa" | "bbb"'
'"aaa bbb"' : '"aaa" | "bbb"' XXX no way to differentiate with the
above for now
'"aaa bbb" ccc' : '"aaa bbb" | "ccc"'
"""
column = self.getColumn()
query_list = []
append = query_list.append
for comparison_operator, value_list in operator_value_dict.iteritems():
if len(value_list) == 1:
value_list = value_list[0].split()
append(SimpleQuery(search_key=self,
comparison_operator=comparison_operator,
group=group, **{column: ' '.join(value_list)}))
group=group, **{column:'"%s"' % '" | "'.join(value_list)}))
return query_list
verifyClass(ISearchKey, SphinxSEFullTextKey)
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