Reputation: 122032
Any idea how to create a lucene Document
from Strings or Textfiles or Directories in the new version of Lucene? Where can i find the API in the current lucene version??
previously in 2_9_4, i could:
IndexWriter = writer = new IndexWriter(indexDir, config);
add(writer, "Lucene");
or even in 3_0_2:
IndexWriter = writer = new IndexWriter(indexDir, config);
writer.addDocument(createDocument("lucene");
But now i'm clueless how the add document goes. How do i add textfile as a lucene Document? or even a Directory of textfiles?
Upvotes: 0
Views: 1581
Reputation: 1497
Hm, among the 3.5 examples I find this (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();
The IndexWriter
is there (http://lucene.apache.org/java/3_5_0/api/core/index.html)...
Are you sure you imported all necessary libraries?
Upvotes: 1