您的位置:首页 > 其它

Lucene深入学习(8)Lucene的索引文件

2017-11-30 23:54 288 查看

生成索引文件

使用最简洁的代价生成一组索引文件。

IndexWriter writer = null;
Directory directory = FSDirectory.open(Paths.get("d://myindex"));
IndexWriterConfig config = new IndexWriterConfig();
writer = new IndexWriter(directory, config);
System.out.println(writer.getConfig());
// 选择一段文本
String text = "In all this Cuban business there is one man stands out on the horizon of my memory like Mars at perihelion.";
Document doc = new Document();
doc.add(new Field("fieldname", text, TextField.TYPE_STORED));
writer.addDocument(doc);
writer.close();


打开索引的存放目录,看到了下面的索引结构。



从这些文件中,可以大致了解到下面的信息:

Lucene的索引是放在一个文件夹中的

索引的各种信息存放在后缀名各异的文件中

有一个锁文件write.lock

实际上,这些文件都各自的职责:

.cfs, .cfe 是复合文件,由系统中使用比较频繁的文件组成

.si 存储段的元数据

segments_x 存储提交点的信息

write.lock 是锁文件
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  lucene 索引 文件