知道如何在新版本的Lucene中使用字符串或文本文件或目录创建lucene Document
吗?我在哪里可以找到当前lucene版本的API ??
之前在2_9_4,我可以:
IndexWriter = writer = new IndexWriter(indexDir, config);
add(writer, "Lucene");
甚至是3_0_2:
IndexWriter = writer = new IndexWriter(indexDir, config);
writer.addDocument(createDocument("lucene");
但是现在我对添加文档的方式毫无头绪。 如何添加文本文件作为lucene文档?甚至是文本文件目录?
答案 0 :(得分:1)
嗯,在我找到的3.5个例子中(http://lucene.apache.org/java/3_5_0/api/contrib-icu/index.html):
Collator collator = Collator.getInstance(new Locale("ar"));
ICUCollationKeyAnalyzer analyzer = new
ICUCollationKeyAnalyzer(collator);
RAMDirectory ramDir = new RAMDirectory();
IndexWriter writer = new IndexWriter(ramDir, analyzer, true, IndexWriter.MaxFieldLength.LIMITED);
Document doc = new Document();
doc.add(new Field("content","\u0633\u0627\u0628", Field.Store.YES,Field.Index.ANALYZED));
writer.addDocument(doc);
writer.close();
IndexWriter
就在那里(http://lucene.apache.org/java/3_5_0/api/core/index.html)......
您确定要导入所有必需的库吗?