动态更改ThinkingSphinx max_matches / offset

时间:2017-06-08 13:46:11

标签: sphinx thinking-sphinx

我们的ThinkingSphinx为一张包含超过5亿条记录的表编制索引。我们正在尝试查找与给定查询匹配的120,000条记录。但是,我不想更改max_matches,因为担心我们的内存不足。

显然,我们得到的错误是:

Exception ThinkingSphinx::SphinxError -> offset out of bounds (offset=100000, max_matches=100000)

<query>
AND `sphinx_deleted` = 0 LIMIT 100000, 1000 OPTION max_matches=100000;

有没有办法:

  1. 如果我没有汇总足够的结果,请动态更改max_matches
  2. 我错过了一个更好的解决方案?

2 个答案:

答案 0 :(得分:0)

您可以根据需要将其设置为 。即将max_matches设置为offset + limit。

LIMIT 100000, 1000 OPTION max_matches=101000LIMIT 7000, 1000 OPTION max_matches=8000

答案 1 :(得分:0)

您可能已经意识到这一点,但以防万一:max_matches中的config/thinking_sphinx.yml设置是绝对最大值。但是,您可以将:max_matches传递给任何搜索查询,以限制该搜索请求的最大结果。

那么,您是否可以将max_matches中的config/thinking_sphinx.yml设置为120,000,然后确保您对除此特定搜索之外的大多数搜索都执行较低的值?

相关问题