try {
db = new RAMDirectory();
docs = documents;
fieldName = fName;
Analyzer analyzer = new WhitespaceAnalyzer();
IndexWriter writer = new IndexWriter(db, analyzer, true);
for (int j = 0; j < docs.length; j++) {
Document d = new Document();
d.add(new Field(fieldName, docs[j], Field.Store.NO, Field.Index.TOKENIZED));
writer.addDocument(d);
}
writer.close();
} catch (java.io.IOException ioe) {
throw new Error(ioe);
}