【问题标题】:Does ThinkingSphinx support offsetting search results?ThinkingSphinx 是否支持抵消搜索结果?
【发布时间】:2017-01-27 20:48:00
【问题描述】:

我一直在研究 ThinkingSphinx 文档,寻找一种将偏移量传递给查询的方法。 Sphinx 本身就支持这个功能

function SetLimits ( $offset, $limit, $max_matches=1000, $cutoff=0 )

但 ThinkingSphinx 文档省略了它。 如果 TS 不支持,是否有解决方法?也许使用 SphinxQL?

提前致谢

【问题讨论】:

标签: ruby-on-rails sphinx thinking-sphinx


【解决方案1】:

似乎可以通过 :page 和 :per_page 间接完成。

http://pat.github.io/thinking-sphinx/searching.html#pagination

【讨论】:

  • 我的理解是,这种方法需要两个查询,这不太理想。 TS 不支持这种常见的 Sphinx 功能似乎很奇怪。谢谢。
【解决方案2】:

好的,这很容易。我不知道我第一次是怎么错过的,但是通过挖掘源我发现 ThinkingSphinx 采用了“偏移”选项。我会说它值得记录。

【讨论】:

    【解决方案3】:

    您可以像下面这样直接指定偏移量和限制

    ThinkingSphinx.search(keyword, :offset => 0, :limit => 5)
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多