如何在Searchlogic查询中添加GROUP_BY子句?

时间:2011-04-01 22:35:02

标签: sql ruby-on-rails ruby searchlogic

我正在使用带有Rails 2.3.5的Searchlogic,我需要在我的查询中添加一个包含2列的GROUP_BY子句。我试过了:

User.search.group = "column1, column2"     # Undefined method 'group'
User.search(:group => "column1, column2")  # Searchlogic::Search::UnknownConditionError: The group is not a valid condition. You may only use conditions that map to a named scope

既不奏效。我在Searchlogic的文档中找不到任何其他方法。还有其他办法吗?

1 个答案:

答案 0 :(得分:0)

根据此页面:http://vladzloteanu.wordpress.com/2009/01/25/searchlogic-plugin-activerecord-search-on-steroids/

您可以使用:

User.search.conditions.group("column1,column2")