Commit 42a0c4d5 authored by Romain Courteaud's avatar Romain Courteaud

Workaround mariadb crazy slow query when using fulltext key.

MroongaFullTextKey is a KeywordKey by default (if user does not enter -/+ operator).
parent 56f1bcd1
......@@ -35,6 +35,6 @@ class MroongaBooleanFullTextKey(MroongaFullTextKey):
This SearchKey generates SQL fulltext comparisons for Mroonga whose
default comparison operator is mroonga_boolean.
"""
default_comparison_operator = 'mroonga_boolean'
default_fulltext_comparison_operator = 'mroonga_boolean'
verifyClass(ISearchKey, MroongaBooleanFullTextKey)
......@@ -26,14 +26,14 @@
#
##############################################################################
from DefaultKey import DefaultKey
from KeywordKey import KeywordKey
from Products.ZSQLCatalog.Query.SimpleQuery import SimpleQuery
from Products.ZSQLCatalog.interfaces.search_key import ISearchKey
from Products.ZSQLCatalog.SearchText import dequote
from zope.interface.verify import verifyClass
class MroongaFullTextKey(DefaultKey):
default_comparison_operator = 'mroonga'
class MroongaFullTextKey(KeywordKey):
default_fulltext_comparison_operator = 'mroonga'
def dequoteParsedText(self):
return False
......@@ -45,6 +45,14 @@ class MroongaFullTextKey(DefaultKey):
# from fulltext='a b' that means fulltext search with (a AND b).
return '(%s)' % (value, )
def _guessComparisonOperator(self, value):
if isinstance(value, basestring) and value[:1] in ('+', '-'):
operator = self.default_fulltext_comparison_operator
else:
operator = super(MroongaFullTextKey,
self)._guessComparisonOperator(value)
return operator
def _processSearchValue(self, search_value, logical_operator,
comparison_operator):
operator_value_dict, logical_operator, parsed = \
......
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