【问题标题】:Filtering a large number of documents in Sphinx在 Sphinx 中过滤大量文档
【发布时间】:2013-06-10 15:53:00
【问题描述】:

在我的应用中,用户可以收藏文档。 Sphinx 用于允许他们搜索匹配的文档。如果用户想要搜索他们的收藏夹,我首先直接进入数据库 (mySQL) 以获取文档 ID 列表并使用它来过滤 sphinx 中的搜索。伪代码如下所示:

function searchFavoritesForUser($userId, $query) {
  $favoriteIds = getFavoriteIdsForUser($userId);
  $sphinx = new Sphinx(...);
  $sphinx->setFilter('document_id', $favoriteIds);
  return $sphinx->search($query);
}

如果用户拥有合理数量的收藏夹,则此方法可以正常工作。如果用户有大量的收藏夹,那么加载收藏夹可能会使用大量内存,并且在 sphinx 中设置过滤器可以在searchd 中再次运行various limits

我意识到我可以调整这些配置值,但似乎必须有更好的方法来设计它。理想情况下,我可以省去必须将所有喜欢的文档 ID 从数据库加载到主内存的步骤。

【问题讨论】:

    标签: sphinx


    【解决方案1】:

    在创建 sphinx 索引时,您可以在 sphinx 中创建MVA (multi-value attribute) 收藏夹(doc_id,user_id),然后直接在 sphinx 中搜索,无需查询 MySql。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2014-06-11
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-10-20
      相关资源
      最近更新 更多