diff options
author | Erik Johnston <erik@matrix.org> | 2015-10-13 15:22:14 +0100 |
---|---|---|
committer | Erik Johnston <erik@matrix.org> | 2015-10-13 15:22:14 +0100 |
commit | 3e2a1297b513dc1fadb288c74684f6651a88016d (patch) | |
tree | 121601d585dc8aa7217cfc8d2cfdae4fc80c6115 /synapse/storage/search.py | |
parent | Merge branch 'develop' of github.com:matrix-org/synapse into erikj/search (diff) | |
download | synapse-3e2a1297b513dc1fadb288c74684f6651a88016d.tar.xz |
Remove constraints in preperation of using filters
Diffstat (limited to '')
-rw-r--r-- | synapse/storage/search.py | 30 |
1 files changed, 10 insertions, 20 deletions
diff --git a/synapse/storage/search.py b/synapse/storage/search.py index 5843f80876..7a30ce25eb 100644 --- a/synapse/storage/search.py +++ b/synapse/storage/search.py @@ -16,38 +16,28 @@ 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): @defer.inlineCallbacks - def search_msgs(self, room_ids, constraints): + def search_msgs(self, room_ids, search_term, keys): clauses = [] args = [] - fts = None clauses.append( "room_id IN (%s)" % (",".join(["?"] * len(room_ids)),) ) args.extend(room_ids) - for c in constraints: - local_clauses = [] - if c.search_type == SearchConstraintTypes.FTS: - fts = c.value - for key in c.keys: - local_clauses.append("key = ?") - args.append(key) - elif c.search_type == SearchConstraintTypes.EXACT: - for key in c.keys: - if key == KnownRoomEventKeys.ROOM_ID: - for value in c.value: - local_clauses.append("room_id = ?") - args.append(value) - clauses.append( - "(%s)" % (" OR ".join(local_clauses),) - ) + local_clauses = [] + for key in keys: + local_clauses.append("key = ?") + args.append(key) + + clauses.append( + "(%s)" % (" OR ".join(local_clauses),) + ) if isinstance(self.database_engine, PostgresEngine): sql = ( @@ -67,7 +57,7 @@ class SearchStore(SQLBaseStore): sql += " ORDER BY rank DESC" results = yield self._execute( - "search_msgs", self.cursor_to_dict, sql, *([fts] + args) + "search_msgs", self.cursor_to_dict, sql, *([search_term] + args) ) events = yield self._get_events([r["event_id"] for r in results]) |