更新lucene到2.3 建立索引遇到的困扰

为了提高索引的速度,利用缓存的方式,达到一定量的时候flush。
lucene2.2版本代码这样写:(部分代码)
IndexWriter fsWriter = new IndexWriter(fsDir,analyzer, true);
addDocument(fsWriter, s); //添加一条信息到Document
if (fsWriter.ramSizeInBytes() > IParaConf.MAXMEMERY) {// 重点:判断内存使用量,大于指定的flush到硬盘。
System.out.println("flush...");
fsWriter.flush();
}

看了lucene2.3的API发现多了一个方法:
public void setRAMBufferSizeMB(double mb)

Determines the amount of RAM that may be used for buffering added documents before they are flushed as a new Segment. Generally for faster indexing performance it's best to flush by RAM usage instead of document count and use as large a RAM buffer as you can.

When this is set, the writer will flush whenever buffered documents use this much RAM. Pass in DISABLE_AUTO_FLUSH to prevent triggering a flush due to RAM usage. Note that if flushing by document count is also enabled, then the flush will be triggered by whichever comes first.

The default value is DEFAULT_RAM_BUFFER_SIZE_MB


于是乎我想既然有了这个方法,我就可以设定好需要的内存,不用再如上那样判断内存使用量了。 可是替换完发现,make index 速度奇慢无比。看一下索引目录,原来在不停的写索引归并文件。 看来这个方法并没有起作用。 无奈,又替换回lucene2.2版本了。
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值