1、
IndexWriter writer = new IndexWriter(INDEX_DIR, new StandardAnalyzer(), true);
它使用的IndexWriter的一个构造函数,定义如下所示:
public IndexWriter(String path, Analyzer a, boolean create)
throws CorruptIndexException, LockObtainFailedException, IOException {
init(FSDirectory.getDirectory(path), a, create, true, null, true);
}
这个构造函数具有三个参数:
[color=red]path [/color] :根据一个字符串描述的路径,为建立的索引文件指定存放目录。
[color=red]a [/color] :一个分析器。
[color=red]create[/color]:它是一个boolean型变量,如果为true,表示要重写指定的存放索引目录下的索引文件;如果为false,表示在指定存放索引目录下已经存在的索引文件的基础上,向其中继续追加新的索引文件。
----------------------------------------------------------------------
IndexWriter writer = new IndexWriter(INDEX_DIR, new StandardAnalyzer(), true);
它使用的IndexWriter的一个构造函数,定义如下所示:
public IndexWriter(String path, Analyzer a, boolean create)
throws CorruptIndexException, LockObtainFailedException, IOException {
init(FSDirectory.getDirectory(path), a, create, true, null, true);
}
这个构造函数具有三个参数:
[color=red]path [/color] :根据一个字符串描述的路径,为建立的索引文件指定存放目录。
[color=red]a [/color] :一个分析器。
[color=red]create[/color]:它是一个boolean型变量,如果为true,表示要重写指定的存放索引目录下的索引文件;如果为false,表示在指定存放索引目录下已经存在的索引文件的基础上,向其中继续追加新的索引文件。
----------------------------------------------------------------------