思考Sphinx未知标识符groupby

时间:2014-08-20 05:52:15

标签: ruby-on-rails thinking-sphinx

我正在根据文档http://pat.github.io/thinking-sphinx/searching.html#grouping尝试使用Thinking Sphinx搜索with group_by选项:

Point.search('point', group_by: :tour_id)

但是这段代码生成了错误的Sphinx查询

SELECT *, groupby() as sphinx_internal_group, count(*) as sphinx_internal_count 
FROM `point_core`, `point_delta` 
WHERE MATCH('point') AND `sphinx_deleted` = 0 
GROUP BY `tour_id` LIMIT 0, 20

会引发错误:

ThinkingSphinx::ParseError: index point_core,point_delta: 
parse error: unknown identifier 'groupby' (not an attribute, not a function) - 
SELECT *, groupby() as sphinx_internal_group, count(*) as sphinx_internal_count 
FROM `point_core`, `point_delta` WHERE MATCH('point') AND `sphinx_deleted` = 0 
GROUP BY `tour_id` LIMIT 0, 20; SHOW META

我正在使用思考-sphinx-3.1.1。

group_by选项使用的正确方法是什么?

1 个答案:

答案 0 :(得分:3)

听起来你正在使用Sphinx 2.0.x - 思考Sphinx v3.1.x默认使用Sphinx 2.1.x.但是你可以configure it以Sphinx 2.0.x期望的方式行事。