-->

Thinking Sphinx unknown identifier groupby

2019-08-05 08:40发布

问题:

I am trying to use Thinking Sphinx search with group_by option according to documentation http://pat.github.io/thinking-sphinx/searching.html#grouping :

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

But this code generates incorrect Sphinx Query

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

which raises error:

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

I am using thinking-sphinx-3.1.1.

What is the correct way of group_by option usage?

回答1:

It sounds like you're using Sphinx 2.0.x - Thinking Sphinx v3.1.x expects Sphinx 2.1.x by default. But you can configure it to behave in ways that Sphinx 2.0.x expects.