dimanche 27 décembre 2015

column "pg_search_***" must appear in the GROUP BY clause or be used in an aggregate function

Tool.select('tools.id, tools.name').search('f')

the above query works fine but

Tool.select('tools.id, tools.name').group('tools.id').search('f')

produces the error

ActiveRecord::StatementInvalid: PG::GroupingError: ERROR: column "pg_search_3aaef8932e30f4464f664f.pg_search_469c73b9b63bebacc2607f" must appear in the GROUP BY clause or be used in an aggregate function LINE 1: ...xt, '')), 'D') || to_tsvector('english', coalesce(pg_search_... I am using pg_search(http://ift.tt/1qZTg4u) gem for full text search..

I am not able to figure out the reason even tried adding

group("tools.id, tools.*, #{PgSearch::Configuration.alias('tools')}.rank")

as mentioned in the read me but still same error.

What is the proper way to frame the query? tq

Aucun commentaire:

Enregistrer un commentaire