solr build 索引时 commit 与 optimize 概念

发布于 2021-08-05 12:40:36 字数 1498 浏览 1407 评论 0

大家都知道,solr 在提交索引的时候有 commit 和 optimize 的概念,今天来分析一下:

1、commit

当你像 solr 提交索引更新时,只有运行了 commit,索引才会发生变化。当然也并不意味着你每次提交都要 commit 如果不是那么紧急,你可以多次提交之后,再执行 commit 操作。

The <commit> operation writes all documents loaded since the last commit to one or more segment files on
the disk. Before a commit has been issued, newly indexed content is not visible to searches. The commit
operation opens a new searcher, and triggers any event listeners that have been configured.
--------------------- 
commit操作将所有需要更新的文档全部写入索引中,但是新进入的索引不会立即生效。

2、optimize

optimize 有点像硬盘上整理磁盘碎片的操作。为了提高搜索速度,它会将索引重组在一起, 然后移除需要被删除删除或是更新的文档,请注意,solr是没有update的这种操作的,只有增加与删除。 solr在优化时,将需要删除或是被替换的索引标记为deleted,然后再创建新的文档替换掉需要被替换的。 optimize就是执行此操作。所以在优化的时候,你的索引会增大,然后再减小。 optimize操作会创建一个全新的的索引结构,所以,你需要预备出2倍于你 commit 时索引大小的空间。

The <optimize> operation requests Solr to merge internal data structures in order to improve search
performance. For a large index, optimization will take some time to complete, but by merging many small
segment files into a larger one, search performance will improve. If you are using Solr’s replication mechanism 
to distribute searches across many systems, be aware that after an optimize, a complete index will need to be 
transferred. In contrast, post-commit transfers are usually much smaller.

optimize操作是合并内部的数据结构来提供搜索性能。对于大型的索引,optimize耗时较多,但是通过合并一些索引结构,到一个大的,那么索引性能会得到提高,需要注意的是一个完整的索引需要传送,对比来说,以post方式进行的提交会更小。

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据

关于作者

JSmiles

生命进入颠沛而奔忙的本质状态,并将以不断告别和相遇的陈旧方式继续下去。

0 文章
0 评论
84959 人气
更多

推荐作者

不再见

文章 0 评论 0

真是无聊啊

文章 0 评论 0

樱娆

文章 0 评论 0

浅语花开

文章 0 评论 0

烛光

文章 0 评论 0

绻影浮沉

文章 0 评论 0

    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文