diff options
author | Erik Johnston <erik@matrix.org> | 2015-10-13 13:47:50 +0100 |
---|---|---|
committer | Erik Johnston <erik@matrix.org> | 2015-10-13 13:47:50 +0100 |
commit | cfd39d6b55fad5b176f1883e1bc87ed8e14acf42 (patch) | |
tree | c50208fd8139254d84b35d756569c8e05af3391c /synapse | |
parent | Merge branch 'erikj/store_engine' into erikj/search (diff) | |
download | synapse-cfd39d6b55fad5b176f1883e1bc87ed8e14acf42.tar.xz |
Add SQLite support
Diffstat (limited to 'synapse')
-rw-r--r-- | synapse/storage/search.py | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/synapse/storage/search.py b/synapse/storage/search.py index 238df38440..5843f80876 100644 --- a/synapse/storage/search.py +++ b/synapse/storage/search.py @@ -17,6 +17,7 @@ from twisted.internet import defer from _base import SQLBaseStore from synapse.api.constants import KnownRoomEventKeys, SearchConstraintTypes +from synapse.storage.engines import PostgresEngine class SearchStore(SQLBaseStore): @@ -48,11 +49,17 @@ class SearchStore(SQLBaseStore): "(%s)" % (" OR ".join(local_clauses),) ) - sql = ( - "SELECT ts_rank_cd(vector, query) AS rank, event_id" - " FROM plainto_tsquery('english', ?) as query, event_search" - " WHERE vector @@ query" - ) + if isinstance(self.database_engine, PostgresEngine): + sql = ( + "SELECT ts_rank_cd(vector, query) AS rank, event_id" + " FROM plainto_tsquery('english', ?) as query, event_search" + " WHERE vector @@ query" + ) + else: + sql = ( + "SELECT 0 as rank, event_id FROM event_search" + " WHERE value MATCH ?" + ) for clause in clauses: sql += " AND " + clause |