Commit 018b0948 authored by Haelwenn's avatar Haelwenn
Browse files

Merge branch 'from/develop/tusooa/2758-gin-index-search' into 'develop'

Make activity search properly use GIN indexes

Closes #2758

See merge request pleroma/pleroma!3519
parents 84ec0fbe a80cb58a
Pipeline #37310 passed with stages
in 92 minutes and 18 seconds
...@@ -17,6 +17,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). ...@@ -17,6 +17,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
## Unreleased-patch ## Unreleased-patch
- Mastodon API: Activity Search fallbacks on status fetching after a DB Timeout/Error - Mastodon API: Activity Search fallbacks on status fetching after a DB Timeout/Error
- Make activity search properly use GIN indexes
## 2.4.0 - 2021-08-xx ## 2.4.0 - 2021-08-xx
......
...@@ -65,10 +65,17 @@ defp restrict_public(q) do ...@@ -65,10 +65,17 @@ defp restrict_public(q) do
end end
defp query_with(q, :gin, search_query, :plain) do defp query_with(q, :gin, search_query, :plain) do
%{rows: [[tsc]]} =
Ecto.Adapters.SQL.query!(
Pleroma.Repo,
"select current_setting('default_text_search_config')::regconfig::oid;"
)
from([a, o] in q, from([a, o] in q,
where: where:
fragment( fragment(
"to_tsvector(?->>'content') @@ plainto_tsquery(?)", "to_tsvector(?::oid::regconfig, ?->>'content') @@ plainto_tsquery(?)",
^tsc,
o.data, o.data,
^search_query ^search_query
) )
...@@ -76,10 +83,17 @@ defp query_with(q, :gin, search_query, :plain) do ...@@ -76,10 +83,17 @@ defp query_with(q, :gin, search_query, :plain) do
end end
defp query_with(q, :gin, search_query, :websearch) do defp query_with(q, :gin, search_query, :websearch) do
%{rows: [[tsc]]} =
Ecto.Adapters.SQL.query!(
Pleroma.Repo,
"select current_setting('default_text_search_config')::regconfig::oid;"
)
from([a, o] in q, from([a, o] in q,
where: where:
fragment( fragment(
"to_tsvector(?->>'content') @@ websearch_to_tsquery(?)", "to_tsvector(?::oid::regconfig, ?->>'content') @@ websearch_to_tsquery(?)",
^tsc,
o.data, o.data,
^search_query ^search_query
) )
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment