ruby-on-rails - Sphinx 增量索引——仍然需要重建主索引吗?

标签 ruby-on-rails ruby full-text-search sphinx thinking-sphinx

我一直在研究 Sphinx 搜索引擎和 Thinking Sphinx gem。在TS docs它说...

Sphinx has one major limitation when compared to a lot of other search services: you cannot update the fields [of] a single document in an index, but have to re-process all the data for that index.

如果我理解正确,那意味着当用户添加或编辑某些内容时,更改不会反射(reflect)在索引中。因此,如果他们添加一条记录,则在重建整个索引之前,它不会出现在搜索中。或者,如果他们删除了一条记录,它出现在搜索中,然后导致某种错误或令人沮丧的行为。

此外,在重建索引时,Sphinx 已关闭。因此,您的应用程序的搜索功能会定期(每小时一次,每隔几小时一次)离线,然后任何尝试进行搜索的人都会收到错误消息或“稍后再试”消息。

好吧,显然这些在现实世界的应用程序中都是 Not Acceptable 。因此,您几乎必须使用增量索引。

但显然你仍然需要定期关闭你的搜索引擎并做一个完整的索引......

Turning on delta indexing does not remove the need for regularly running a full re-index, as otherwise the delta index itself will grow to become just as large as the core indexes, and this removes the advantage of keeping it separate. It also slows down your requests to your server that make changes to the model records.

我真的不明白这里的文档在说什么。也许有人可以帮助我。我认为增量索引的全部意义在于您不需要定期重建索引。只要数据发生变化,它就会立即更新。

因为每小时或每一次重建索引都会完全搞砸,对吧?

最佳答案

If I understand correctly, that means when a user adds or edits something, the change is not reflected in the index. So if they add a record it won't come up in searches until the entire index is rebuilt. Or if they delete a record, it will come up in searches, and then cause some kind of error or frustrating behavior. Moreover, while rebuilding the index Sphinx is shut down. ...

您不需要重建索引 - 只需重新索引它们。这意味着 - 无需停止守护进程。只有在更改索引结构后才需要重建 - 而这里不是这种情况。

对于第二部分 - 同样,您不需要重建索引,因此没有必要停止守护进程。当使用增量索引时,实际上有两个用于搜索的索引——主索引(应该每隔一段时间重新索引一次)和增量索引(在记录的每个相关操作后刷新)。如果我理解正确的话,当重新索引主索引时(例如,通过 cron 任务),delta 索引只是合并到主索引中,所以它不会占用那么多地方并保持快速。

关于ruby-on-rails - Sphinx 增量索引——仍然需要重建主索引吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1781455/

相关文章:

ruby-on-rails - 测试中的 RSpec 路由错误但应用程序中没有

ruby-on-rails - 如何修复此语法错误?

ruby-on-rails - 使用 Mongo 运行 'bootstrap:themed' 时出现 Twitter Bootstrap 错误

ruby - Nokogiri 将值作为字符串而不是数组返回

postgresql - Postgresql下使用to_tsquery搜索奇怪的结果

rails 3.1 中未读取 css 文件

ruby-on-rails - 找到 id = 1 的 Zombie 并将其存储在变量中

full-text-search - Solr查询唯一整数字段

ios - CoreData 的 iOS 搜索时间令人失望

ruby - 跨棋盘算法改进