【问题标题】:Sphinx - Filter One Index, Search another Full TextSphinx - 过滤一个索引,搜索另一个全文
【发布时间】:2012-09-11 22:58:45
【问题描述】:

对于房地产门户网站,代理商会记录每天有多少开放参观的客人出现。我正在尝试使用 sphinx api 在名为“open_house_guest_info”的 sphinx 索引中过滤访问次数最多的房屋,然后在另一个带有房屋介绍“houses”的 sphinx 索引中搜索这些房屋 ID,并带有搜索词。

“open_house_guest_info”索引:
日期、house_id、guest_count

“房屋”索引:
house_id, house_intro

我知道如何用 MySQL 做到这一点,但我正在尝试用 Sphinx 做到这一点。如何根据从与“house_id”绑定的另一个索引过滤的属性来搜索不同索引的文本?

【问题讨论】:

    标签: search indexing sphinx


    【解决方案1】:

    Sphinx 无法“加入”索引。您必须将所有数据放在一个索引中。

    建立索引的sql_query,可以包含JOINs,GROUP BYs等。由mysql执行创建一个单一的索引。

    sql_query = SELECT g.id,house_id,house_intro,REPLACE(date,'-','') as date,COUNT(g.id) AS guests FROM houses h INNER JOIN open_house_guest_info g USING (house_id) GROUP BY date,house_id
    
    sql_attr_uint = house_id
    sql_attr_uint = date
    sql_attr_uint = guests
    

    然后可以按日期、house_id 或客人过滤/分组/排序:) [在 sphinx 查询中]

    【讨论】:

      猜你喜欢
      • 2014-05-01
      • 2015-01-29
      • 2018-06-22
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多