当您向 SQL 添加数据时,Sphinx 自动更新索引吗?
我很好奇当您添加新的 SQL 数据时 Sphinx 是否会自动更新其索引,或者您是否必须专门告诉它重新索引您的数据库。
如果没有,是否有人有一个示例来说明如何在数据库数据更改时自动执行此过程?
I am curious as to whether or not Sphinx will auto update its index when you add new SQL data or whether you have to tell it specifically to reindex your db.
If it doesn't, does anyone have an example of how to automate this process when the database data changes?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
答案是否定的,您需要告诉 sphinx 重新索引您的数据库。
您需要了解一些步骤和要求:
如在 sphinx 文档中 http://sphinxsearch.com/docs/current.html#index-合并
重新启动sphinx服务。
提示:使用 C# 或其他语言创建您自己的可以执行索引的程序。你可以试试windows的任务计划也可以。
这是我的会议:
The answer is no and you need to tell sphinx to reindex your db.
There are some steps and requirements which you need to know:
as inside the sphinx documents http://sphinxsearch.com/docs/current.html#index-merging
Restart sphinx service.
TIPS: Create your own program that could execute the index by using C# or other languages. You may try the task schedule of windows also can.
Here is my conf:
如有关实时索引的sphinx文档部分中所示
因此,要动态更新索引,您只需要进行如下查询
As found in the sphinx documentation part about real-time indexes
So to update an index on the fly you would just need to make a query like
扩展 Anne 的答案 - 如果您使用 SQL 索引,它不会自动更新。您可以在每次更改后管理重新索引的过程 - 但这可能会很昂贵。解决这个问题的一种方法是使用包含所有内容的核心索引,然后使用具有相同结构的增量索引来仅对更改进行索引(这可以通过布尔值或时间戳列来完成)。
这样,您就可以超级定期地重新索引增量索引(更小,因此更快),然后不定期地一起处理核心和增量(但仍然最好至少每天执行一次)。
但除此之外,新的 RT 指数值得关注 - 您仍然需要自己更新内容,并且它与数据库无关,因此这是一种不同的思维方式。另外:RT 索引不具备 SQL 索引所具有的所有功能,因此您需要决定什么更重要。
To expand on Anne's answer - if you're using SQL indices, it won't update automatically. You can manage the process of reindexing after every change - but that can be expensive. One way to get around this is have a core index with everything, and then a delta index with the same structure that indexes just the changes (this could be done by a boolean or timestamp column).
That way, you can just reindex the delta index (which is smaller, and thus faster) on a super-regular basis, and then process both core and delta together less regularly (but still, best to do it at least daily).
But otherwise, the new RT indices are worth looking at - you still need to update things yourself, and it's not tied to the database, so it's a different mindset. Also: RT indices don't have all the features that SQL indices do, so you'll need to decide what's more important.