Lucene深入学习(5)Lucene的IndexWriter
来源:互联网 发布:淘宝怎么搜索旺旺号 编辑:程序博客网 时间:2024/06/05 05:28
摘要: Lucene的索引器IndexWriter主要是创建索引,合并索引,控制索引的创建过程。本次代码示例基于Lucene 6.2.1.
获得IndexWriter
想要获得IndexWriter实例,需要用到唯一的构造器:
public IndexWriter(Directory d, IndexWriterConfig conf)
第一个参数指定了索引地址,第二个参数就是索引的配置信息了。Lucene使用IndexWriterConfig封装了所有索引时需要的设置的内容,它含有的丰富的内容,定义了许多默认值。
可以通过下面的方式拿到索引时的配置信息:
Directory directory = FSDirectory.open(Paths.get("d://myindex")); IndexWriterConfig config = new IndexWriterConfig(); writer = new IndexWriter(directory, config); System.out.println(writer.getConfig());
我的Lucene默认的配置信息如下:
analyzer=org.apache.lucene.analysis.standard.StandardAnalyzerramBufferSizeMB=16.0maxBufferedDocs=-1maxBufferedDeleteTerms=-1mergedSegmentWarmer=nulldelPolicy=org.apache.lucene.index.KeepOnlyLastCommitDeletionPolicycommit=nullopenMode=CREATE_OR_APPENDsimilarity=org.apache.lucene.search.similarities.BM25SimilaritymergeScheduler=ConcurrentMergeScheduler: maxThreadCount=-1, maxMergeCount=-1, ioThrottle=truecodec=Lucene62infoStream=org.apache.lucene.util.InfoStream$NoOutputmergePolicy=[TieredMergePolicy: maxMergeAtOnce=10, maxMergeAtOnceExplicit=30, maxMergedSegmentMB=5120.0, floorSegmentMB=2.0, forceMergeDeletesPctAllowed=10.0, segmentsPerTier=10.0, maxCFSSegmentSizeMB=8.796093022207999E12, noCFSRatio=0.1indexerThreadPool=org.apache.lucene.index.DocumentsWriterPerThreadPool@1fbc7afbreaderPooling=falseperThreadHardLimitMB=1945useCompoundFile=truecommitOnClose=trueindexSort=nullwriter=org.apache.lucene.index.IndexWriter@45c8e616
添加索引文档
IndexWriter()准备好后,就可以添加文档Document了。IndexWriter使用到了下面两个简单的添加接口:
public long addDocument(Iterable<? extends IndexableField> doc)public long addDocuments(Iterable<? extends Iterable<? extends IndexableField>> docs)
乍一看,它们没有区别。实际上,第一个适合添加单个文档,下面的添加多个文档。
阅读全文
0 0
- Lucene深入学习(5)Lucene的IndexWriter
- Lucene的IndexWriter
- Lucene-indexWriter
- Lucene--IndexWriter
- Lucene深入学习(5)Lucene的Document与Field
- 一步一步跟我学习lucene(1)---lucene的IndexWriter对象创建和索引策略的选择
- 利用Lucene的IndexWriter建立索引(详解)
- Lucene深入学习(7)Lucene的索引过程
- Lucene深入学习(8)Lucene的索引文件
- Lucene的IndexWriter初始化时的LockObtainFailedException
- Lucene 深入学习(2)Lucene简介
- lucene---创建IndexWriter对象
- Lucene的IndexWriter初始化时的LockObtainFailedException的解决方法
- Lucene的IndexWriter初始化时的LockObtainFailedException的解决方法
- Lucene的IndexWriter初始化时的LockObtainFailedException的解决方法
- Lucene 深入学习(3)Lucene索引初识
- Lucene 深入学习(4)Lucene索引实现方式
- lucene管理IndexReader和IndexWriter的最佳实践
- Python语言入门(四)字典与Set集合用法体验
- 深度学习2:为什么深度学习要使用numpy库
- leetcode011-Best Time to Buy and Sell Stock with Transaction Fee
- ASP.NET中UpdatePanel内JS失效的解决办法
- 从运维角度看中大型网站架构的演变之路
- Lucene深入学习(5)Lucene的IndexWriter
- Centos 7 学习之静态IP设置
- 第一次来
- DOS下常用网络相关命令解释
- 【object detection】RCNN 实践篇
- 【Python语法笔记】字符串的操作
- 用户手势检测-GestureDetector使用详解
- IDEA 常用快捷键
- Python之end()关键字使用