Lucene 中的段是什么? [英] What are segments in Lucene?

查看:12
本文介绍了Lucene 中的段是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Lucene 中的段是什么?

细分有什么好处?

推荐答案

Lucene 索引被分成更小的块,称为段.每个段都是它自己的索引.Lucene 按顺序搜索所有这些.

The Lucene index is split into smaller chunks called segments. Each segment is its own index. Lucene searches all of them in sequence.

当一个新的写入器被打开和一个写入器提交或关闭时,一个新的段被创建.

A new segment is created when a new writer is opened and when a writer commits or is closed.

使用此系统的优点是,您无需在创建段后对其文件进行修改.当您在索引中添加新文档时,它们会被添加到下一个片段中.以前的段永远不会被修改.

The advantages of using this system are that you never have to modify the files of a segment once it is created. When you are adding new documents in your index, they are added to the next segment. Previous segments are never modified.

删除文档是通过在文件中简单地指出一个段的哪个文档被删除来完成的,但在物理上,该文档始终保留在段中.Lucene 中的文档并没有真正更新.发生的情况是文档的先前版本在其原始段中被标记为已删除,并且文档的新版本被添加到当前段中.这通过在发生更改时不断修改其内容来最大限度地减少损坏索引的机会.它还允许在不同机器上轻松备份和同步索引.

Deleting a document is done by simply indicating in a file which document of a segment is deleted, but physically, the document always stays in the segment. Documents in Lucene aren't really updated. What happens is that the previous version of the document is marked as deleted in its original segment and the new version of the document is added to the current segment. This minimizes the chances of corrupting an index by constantly having to modify its content when there are changes. It also allows for easy backup and synchronization of the index across different machines.

但是,在某些时候,Lucene 可能会决定合并某些段.此操作也可以通过优化触发.

However, at some point, Lucene may decide to merge some segments. This operation can also be triggered with an optimize.

这篇关于Lucene 中的段是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆