如何在Lucene中正确使用multireader API?

发布于 2024-12-28 11:32:03 字数 372 浏览 0 评论 0原文

我有几个索引,但想知道哪种使用方式是正确的。

IndexReader r1= IndexReader.open(...)
IndexReader r2= IndexReader.open(...)
MultiReader mr= new MultiReader(r1,r2)

1)

IndexSearcher s = new IndexSearcher(mr);

2)

IndexSearcher s = new IndexSearcher(mr,new IndexReader[]{r1,r2}....

哪一项是正确的?

I have several indexes, but wanted to know which way of using is correct.

IndexReader r1= IndexReader.open(...)
IndexReader r2= IndexReader.open(...)
MultiReader mr= new MultiReader(r1,r2)

1)

IndexSearcher s = new IndexSearcher(mr);

2)

IndexSearcher s = new IndexSearcher(mr,new IndexReader[]{r1,r2}....

Which one is correct?

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

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

发布评论

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

评论(1

栀子花开つ 2025-01-04 11:32:03

您应该坚持遵循 Lucene API 文档,

IndexSearcher s = new IndexSearcher(mr);

在大多数版本的 Lucene 库中,接受子阅读器(IndexSearchders 的附加数组)的 IndexSearcher 的构造函数用法都标有警告,不鼓励其使用,

IndexSearcher s = new IndexSearcher(mr,new IndexReader[]{r1,r2}....

标有 '警告:此 API 是实验性的,并且可能在下一版本中以不兼容的方式进行更改。'。我猜引入这些额外的构造函数选项的原因是为了促进内部 Lucene 子类化,请参阅 上的评论LUCENE-1925

Going by Lucene API Doc you should stick to,

IndexSearcher s = new IndexSearcher(mr);

In most versions of Lucene Library, constructor usages of IndexSearcher that accepts subreaders (additional array of IndexSearchders) are marked with warning discouraging their use,

IndexSearcher s = new IndexSearcher(mr,new IndexReader[]{r1,r2}....

is marked with 'WARNING: This API is experimental and might change in incompatible ways in the next release.'. I guess the reason those additional constructors options introduced was to facilitate internal Lucene Subclassing, please refer to comments on LUCENE-1925

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