代码之家  ›  专栏  ›  技术社区  ›  SunnyMagadan

思考斯芬克斯未知标识符groupby

  •  1
  • SunnyMagadan  · 技术社区  · 10 年前

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

    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
    

    我正在使用thinking-sphinx-3.1.1。

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

    1 回复  |  直到 10 年前
        1
  •  3
  •   pat    10 年前

    听起来您使用的是Sphinx 2.0.x-Thinking Sphinx v3.1.x默认使用Sphinx 2.1.x。但你可以 configure it 以Sphinx 2.0.x期望的方式运行。