Use plainto_tsquery instead of to_tsquery to allow multiple words

This commit is contained in:
Yohan Boniface 2015-12-23 22:03:09 +01:00
parent d99a208226
commit d7649b3a66

View file

@ -141,7 +141,7 @@ class Search(TemplateView, PaginatorMixin):
q = self.request.GET.get('q') q = self.request.GET.get('q')
results = [] results = []
if q: if q:
where = "to_tsvector(name) @@ to_tsquery(%s)" where = "to_tsvector(name) @@ plainto_tsquery(%s)"
if getattr(settings, 'UMAP_USE_UNACCENT', False): if getattr(settings, 'UMAP_USE_UNACCENT', False):
where = "to_tsvector(unaccent(name)) @@ to_tsquery(unaccent(%s))" # noqa where = "to_tsvector(unaccent(name)) @@ to_tsquery(unaccent(%s))" # noqa
results = Map.objects.filter(share_status=Map.PUBLIC) results = Map.objects.filter(share_status=Map.PUBLIC)