Skip to content


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP


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

gregolsen opened this Issue · 9 comments

5 participants


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} }




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

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


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


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?


@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 =').where . . .


@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


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?


@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.


@chuckweinberger thanks for pointing that out!



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
  .joins("left outer join companies ON = users.company_id")
  .page params[:page]

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.