Skip to content

Commit

Permalink
CQL: do not perform PG tsquery operations for fuzzy searches
Browse files Browse the repository at this point in the history
  • Loading branch information
tomkralidis authored and kalxas committed Sep 21, 2023
1 parent d149905 commit eec0fce
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions pycsw/core/pygeofilter_evaluate.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,18 +63,20 @@ def bbox(self, node, lhs):
@handle(ast.Like)
def ilike(self, node, lhs):
LOGGER.debug('Overriding ILIKE filter handling')
LOGGER.debug(f'Term: {node.pattern}')
if (str(lhs.prop) == 'dataset.anytext' and
self._pycsw_dbtype.startswith('postgres')):
LOGGER.debug('Kicking into PostgreSQL FTS mode')
return text(f"plainto_tsquery('english', '{node.pattern}') @@ anytext_tsvector") # noqa
else:
LOGGER.debug('Default ILIKE behaviour')
return filters.like(
lhs,
node.pattern,
not node.nocase,
node.not_,
)
if '%' not in node.pattern:
LOGGER.debug('Kicking into PostgreSQL FTS mode')
return text(f"plainto_tsquery('english', '{node.pattern}') @@ anytext_tsvector") # noqa

LOGGER.debug('Default ILIKE behaviour')
return filters.like(
lhs,
node.pattern,
not node.nocase,
node.not_
)


def to_filter(ast, dbtype, field_mapping=None):
Expand Down

0 comments on commit eec0fce

Please sign in to comment.