创建lucene indexWriter的开销?

发布于 2024-11-28 03:19:39 字数 265 浏览 4 评论 0原文

<代码>

IndexWriter myWriter = new IndexWriter(pathOnDisk);
int segCount = myWriter.GetSegmentCount();
if (segCount > 1)
   myWriter.Optimize();
myWriter.Close()

我想为 50 个不同的索引目录运行上面的代码,所以我想知道打开索引编写器是否有开销?

IndexWriter myWriter = new IndexWriter(pathOnDisk);
int segCount = myWriter.GetSegmentCount();
if (segCount > 1)
   myWriter.Optimize();
myWriter.Close()

I want to run the above code for 50 different index directory, so i want to know if opening an indexwriter has overhead ?

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

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

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

靑春怀旧 2024-12-05 03:19:39

它有一些开销,包括创建一个锁文件(参见第 133 行)、读取段信息以及一堆其他可能很昂贵也可能不昂贵的东西。

0113 打开 IndexWriter 会为正在使用的目录创建一个锁定文件。正在尝试打开
同一目录上的另一个 IndexWriter 将导致
{@link LockObtainFailedException}。 {@link LockObtainFailedException}
如果使用同一目录上的 IndexReader 删除文档也会抛出该错误
来自索引。

查看 java 源代码,从第 816 行开始。它不是一个小构造函数,但您必须判断它的重要性。

It has some overhead, including creating a lock file (see line 133), reading the segment infos, and a bunch of other stuff that may or may not be expensive.

0113 Opening an IndexWriter creates a lock file for the directory in use. Trying to open
another IndexWriter on the same directory will lead to a
{@link LockObtainFailedException}. The {@link LockObtainFailedException}
is also thrown if an IndexReader on the same directory is used to delete documents
from the index.

Check out the java source, starting at line 816. It's not a small constructor, but you'll have to be the judge of how significant it is.

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