From 33f551fb21d9b4b66196271b561396c86945a62b Mon Sep 17 00:00:00 2001 From: Andrew Shu Date: Wed, 15 Jul 2020 12:35:43 -0700 Subject: [PATCH] Remove period chars from search query for multilevel tags Tags are stored in the search index as space-separated strings with the periods removed. Searches for "parent.child" tags were failing because of the period. Removing period is okay for now because URL domains are not currently indexed for search. --- tildes/tildes/models/topic/topic_query.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/tildes/tildes/models/topic/topic_query.py b/tildes/tildes/models/topic/topic_query.py index 0d96767..32897b9 100644 --- a/tildes/tildes/models/topic/topic_query.py +++ b/tildes/tildes/models/topic/topic_query.py @@ -216,6 +216,11 @@ class TopicQuery(PaginatedQuery): def search(self, query: str) -> "TopicQuery": """Restrict the topics to ones that match a search query (generative).""" + # Replace "." with space, since tags are stored as space-separated strings + # in the search index. + # URL domains are not indexed, so removing "." is okay for now. + query = query.replace(".", " ") + return self.filter(Topic.search_tsv.op("@@")(func.websearch_to_tsquery(query))) def only_bookmarked(self) -> "TopicQuery":