fulltext search in macosx

This commit is contained in:
j 2019-01-15 14:08:42 +05:30
commit 1c8a5c3764
5 changed files with 59 additions and 2 deletions

View file

@ -9,6 +9,7 @@ from sqlalchemy.sql.expression import text
import utils
import settings
from fulltext import find_fulltext
import logging
logger = logging.getLogger(__name__)
@ -25,7 +26,7 @@ def get_operator(op, type='str'):
'$': operators.endswith_op,
'&': operators.in_op,
},
'int': {
'int': {
'==': operators.eq,
'>': operators.gt,
'>=': operators.ge,
@ -65,7 +66,7 @@ class Parser(object):
...
'''
#logger.debug('parse_condition %s', condition)
if not 'value' in condition:
if 'value' not in condition:
return None
k = condition.get('key', '*')
if not k:
@ -122,6 +123,18 @@ class Parser(object):
in_op = operators.notin_op if exclude else operators.in_op
q = in_op(self._model.id, ids)
return q
elif k == 'fulltext':
ids = find_fulltext(v)
if ids:
in_op = operators.notin_op if exclude else operators.in_op
q = in_op(self._model.id, ids)
else:
# nothing
q = operators.eq(self._model.id, -1)
if exclude:
q = ~q
return q
elif key_type in ("string", "text"):
if isinstance(v, str):
v = unicodedata.normalize('NFKD', v).lower()