Revert "Fix #994: use PostgreSQL full-text-search"

This reverts commit b3d8d6a4da.
This commit is contained in:
Eliot Berriot 2019-12-17 10:57:05 +01:00
parent b3d8d6a4da
commit 7b0db234e2
No known key found for this signature in database
GPG key ID: 6B501DFD73514E14
6 changed files with 5 additions and 148 deletions

View file

@ -1,6 +1,5 @@
import re
from django.contrib.postgres.search import SearchQuery
from django.db.models import Q
@ -57,17 +56,6 @@ def get_query(query_string, search_fields):
return query
def get_fts_query(query_string):
if not query_string.startswith('"') and not query_string.endswith('"'):
parts = query_string.split(" ")
parts = ["{}:*".format(p) for p in parts if p]
if not parts:
return Q(pk=None)
query_string = "&".join(parts)
return Q(body_text=SearchQuery(query_string, search_type="raw"))
def filter_tokens(tokens, valid):
return [t for t in tokens if t["key"] in valid]