Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Matrix
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Container Registry
Model registry
Operate
Environments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
TeDomum
Matrix
Commits
841054ad
Commit
841054ad
authored
5 years ago
by
Brendan Abolivier
Browse files
Options
Downloads
Patches
Plain Diff
Move search's bg updates to a dedicated store
parent
81e6ffb5
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
synapse/storage/search.py
+31
-25
31 additions, 25 deletions
synapse/storage/search.py
with
31 additions
and
25 deletions
synapse/storage/search.py
+
31
−
25
View file @
841054ad
...
...
@@ -36,7 +36,7 @@ SearchEntry = namedtuple(
)
class
SearchStore
(
BackgroundUpdateStore
):
class
Search
BackgroundUpdate
Store
(
BackgroundUpdateStore
):
EVENT_SEARCH_UPDATE_NAME
=
"
event_search
"
EVENT_SEARCH_ORDER_UPDATE_NAME
=
"
event_search_order
"
...
...
@@ -44,7 +44,7 @@ class SearchStore(BackgroundUpdateStore):
EVENT_SEARCH_USE_GIN_POSTGRES_NAME
=
"
event_search_postgres_gin
"
def
__init__
(
self
,
db_conn
,
hs
):
super
(
SearchStore
,
self
).
__init__
(
db_conn
,
hs
)
super
(
Search
BackgroundUpdate
Store
,
self
).
__init__
(
db_conn
,
hs
)
if
not
hs
.
config
.
enable_search
:
return
...
...
@@ -289,29 +289,6 @@ class SearchStore(BackgroundUpdateStore):
return
num_rows
def
store_event_search_txn
(
self
,
txn
,
event
,
key
,
value
):
"""
Add event to the search table
Args:
txn (cursor):
event (EventBase):
key (str):
value (str):
"""
self
.
store_search_entries_txn
(
txn
,
(
SearchEntry
(
key
=
key
,
value
=
value
,
event_id
=
event
.
event_id
,
room_id
=
event
.
room_id
,
stream_ordering
=
event
.
internal_metadata
.
stream_ordering
,
origin_server_ts
=
event
.
origin_server_ts
,
),
),
)
def
store_search_entries_txn
(
self
,
txn
,
entries
):
"""
Add entries to the search table
...
...
@@ -358,6 +335,35 @@ class SearchStore(BackgroundUpdateStore):
# This should be unreachable.
raise
Exception
(
"
Unrecognized database engine
"
)
class
SearchStore
(
SearchBackgroundUpdateStore
):
def
__init__
(
self
,
db_conn
,
hs
):
super
(
SearchStore
,
self
).
__init__
(
db_conn
,
hs
)
def
store_event_search_txn
(
self
,
txn
,
event
,
key
,
value
):
"""
Add event to the search table
Args:
txn (cursor):
event (EventBase):
key (str):
value (str):
"""
self
.
store_search_entries_txn
(
txn
,
(
SearchEntry
(
key
=
key
,
value
=
value
,
event_id
=
event
.
event_id
,
room_id
=
event
.
room_id
,
stream_ordering
=
event
.
internal_metadata
.
stream_ordering
,
origin_server_ts
=
event
.
origin_server_ts
,
),
),
)
@defer.inlineCallbacks
def
search_msgs
(
self
,
room_ids
,
search_term
,
keys
):
"""
Performs a full text search over events with given keys.
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment