pg_search builds ActiveRecord named scopes that take advantage of PostgreSQL's full text search
Rating.where(foo: 'bar').my_custom_scope.joins(:pg_search_document).merge(PgSearch.multisearch('my query'))
. This may be able to work because PgSearch.multisearch
returns a scope of PgSearch::Document
records.
WHERE (((to_tsvector('simple', coalesce("pg_search_documents"."content"::text, ''))) @@ (to_tsquery('simple', ''' ' || 'tyng' || ' ''')))
OR ((coalesce("pg_search_documents"."content"::text, '')) % 'tyng')
OR ((to_tsvector('simple', pg_search_dmetaphone(coalesce("pg_search_documents"."content"::text, '')))) @@ (to_tsquery('simple', ''' ' || pg_search_dmetaphone('tyng') || ' '''))))) AS pg_search_ce9b9dd18c5c0023f2116f ON "pg_search_documents"."id" = pg_search_ce9b9dd18c5c0023f2116f.pg_search_id
create index test_text_index1 on pg_search_documents using gin(((to_tsvector('simple'::regconfig, coalesce(content, ''::text)))));
create index test_text_index2 on pg_search_documents using gin(((to_tsvector('simple'::regconfig, pg_search_dmetaphone(coalesce(content, ''::text))))));
create index test_text_index4 on pg_search_documents using gist(coalesce(content, ''::text) gist_trgm_ops)
#multisearchable
the same way it's done in #pg_search_scope
?
pg_search
on Heroku for the last 4.5 years and am very happy with ease of configuration and performance I have been able to get.