Lucene 创建重复索引

发布于 2024-10-26 19:32:23 字数 250 浏览 5 评论 0原文

我使用 lucene 创建了一个应用程序。服务器最终抛出内存不足错误,因为我是应用程序中每次搜索的 IndexSeacher 新手。垃圾收集器跟不上。

我刚刚完成了单例方法的实现,现在正在创建多个索引。

在此处输入图像描述

知道为什么会发生这种情况吗? IndexWriter 是我保持静态的。我从中得到 IndexSearchers。

I created an app using lucene. The server winded up throwing out of memory errors because I was new'in up an IndexSeacher for every search in the app. The garbage collector couldn't keep up.

I just got done implementing a singleton approach and now there are multiple indexes being created.

enter image description here

Any clue why this is happening? IndexWriter is what I am keeping static. I get IndexSearchers from it.

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

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

发布评论

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

评论(2

染年凉城似染瑾 2024-11-02 19:32:23

您没有多个索引,只有多个段。随着时间的推移,Lucene 将索引分割成多个段,但如果您愿意,您也可以将其压缩。

请参阅此处此处了解更多信息

You don't have multiple indexes, you just have multiple segments. Lucene splits the index up into segments over time, although you can compact it if you want.

See here and here for more info

半步萧音过轻尘 2024-11-02 19:32:23

您可能还想“新建”一个 IndexSearcher 并将其传递给周围,似乎您每次都在这里创建索引。

You also probably want to "new up" one IndexSearcher and pass it around, seems like you are creating the index every time here.

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