Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Error: PG::Error: ERROR: column "pg_search_rank" does not exist #110

Closed
gregolsen opened this Issue · 9 comments

5 participants

@gregolsen

pg_search 0.6.1 fails to build a query when includes used and dot is present in the string

My model config:

pg_search_scope :full_text_search,
                against: :content,
                using: { tsearch: {prefix: true} }

Query:

Message.full_text_search("to@domain.com").includes(:recipients)

Error:

Error: PG::Error: ERROR:  column "pg_search_rank" does not exist

Looks like this bug was present before and was fixed #14

@chuckweinberger

And see issue #109 for what appears to be a bug that is triggered by the fix of #14.

@hallmatt

I'm getting this same error as well.

scope :public_view, includes(:status).where("inventory_statuses.code in ('S','V','R','P','D','C') AND machines.is_active = true AND machines.show_on_web = true")

The scope works fine if I switch the includes to joins. Any ideas?

@chuckweinberger

@hallmatt, work-around is to create your left joins manually instead of relying on includes.

Something like: Machine.joins('LEFT OUTER JOIN status ON status.machines_id = machines.id').where . . .

@gregolsen

@chuckweinberger this workaround will work only if you want to filter data but if you want to load associations and access them later on you still need includes

@hallmatt

Thanks @gregolsen. Includes is necessary in the case, as I'm using the associations and data later on in the views. Anyway we can get a fix for this issue?

@chuckweinberger

@gregolsen, true, but as @maxwell pointed out in #109, you can combine the joins with ActiveRecord#preload so to actively load the associations without using includes.

@gregolsen

@chuckweinberger thanks for pointing that out!

@leckylao

+1.

Thanks @gregolsen and @chuckweinberger for the workaround of preload and joins. Hopefully this issue can be resolve soon. Here's code of how I use it

@users = User
  .preload(:company)
  .joins("left outer join companies ON companies.id = users.company_id")
  .search(params[:term])
  .page params[:page]
@nertzy
Owner

Closing this because pg_search 1.0 uses a different strategy to build the query. Please open a new issue if you have problems going forward.

@nertzy nertzy closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.