Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Partial fix for #879 #904

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions pycsw/core/pygeofilter_evaluate.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,16 @@ def ilike(self, node, lhs):
LOGGER.debug(f'Term: {node.pattern}')
if (str(lhs.prop) == 'dataset.anytext' and
self._pycsw_dbtype.startswith('postgres')):
if '%' not in node.pattern:
if not node.pattern.startswith('%'):
LOGGER.debug('Kicking into PostgreSQL FTS mode')
return text(f"plainto_tsquery('english', '{node.pattern}') @@ anytext_tsvector") # noqa
if node.pattern.endswith('%'):
LOGGER.debug('Fuzzy term search')
term = node.pattern.replace('%', ':*')
else:
LOGGER.debug('Normal term search')
term = node.pattern
LOGGER.debug(f"FTS term: {term}")
return text(f"to_tsquery('english', '{term}') @@ anytext_tsvector") # noqa

LOGGER.debug('Default ILIKE behaviour')
return filters.like(
Expand Down
Loading