Casecommons / pg_search

pg_search builds ActiveRecord named scopes that take advantage of PostgreSQL’s full text search
http://www.casebook.net
MIT License
1.3k stars 369 forks source link

How to search for everything #458

Open antarr opened 3 years ago

antarr commented 3 years ago

I'm switching from searchkick which uses elastic search. In that library, you are able to search for everything using * like `.

Searchkick.search('*',
                      where: { updated_at: { gt: since }, state_id: filters[:state_id] },
                      models: search_models,
                      order: sorting,
                      boost_by_recency: { created_at: { scale: '7d', decay: 0.5 } },
                      page: params[:page], per_page: 10)

Does pg_search provide anything like this when using multisearchable?

archonic commented 1 year ago

I just avoid calling search on the relation. Like this:

results = Document.where(where_conditions)
results = results.search(params[:q]) if !params[:q].blank?
@pagy, @documents = pagy(results)