构造一个IndexWriter对象的流程总体分为下面三个部分:
- 设置索引目录Directory
- 设置IndexWriter的配置信息IndexWriterConfig
- 调用IndexWriter的构造函数
大家可以查看文章构造IndexWriter对象(一)、构造IndexWriter对象(二)来了解前两部分的内容,我们接着继续介绍最后一个部分,即调用IndexWriter的构造函数。
IndexWriter类有且仅有一个有参构造函数,如下所示:
public IndexWriter(Directory d, IndexWriterConfig conf) throws IOException {
... ...
}
其中参数d以及conf正是分别由设置索引目录Directory
、设置IndexWriter的配置信息IndexWriterConfig
两部分获得。
调用IndexWriter的构造函数的流程图
图1:
看这里:https://www.amazingkoala.com.cn/Lucene/Index/2019/1118/108.html