Skip to content

Advanced Search Queries#407

Open
skryl wants to merge 2 commits into
Casecommons:masterfrom
nutrisense:master
Open

Advanced Search Queries#407
skryl wants to merge 2 commits into
Casecommons:masterfrom
nutrisense:master

Conversation

@skryl

@skryl skryl commented Jun 1, 2019

Copy link
Copy Markdown
:advanced

Setting this attribute to true will allow you to pass advanced search queries directly to postgres, without pg_search doing any processing on the terms.

class Number < ActiveRecord::Base
  include PgSearch
  pg_search_scope :advanced_search,
                  against: :text,
                  using: {
                    tsearch: {advanced: true}
                  }
end

one = Number.create! text: 'one two three'
one = Number.create! text: 'one three two'

Number.advanced_search('one<->two') # => ['one two three']

See the
documentation
for details on the meaning of each option.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant