logger.info("Creating index directory {}", indexDir);
indexDir.mkdirs();
}
public void index() throws IOException {
final SimpleIndexer indexer = new SimpleIndexer(indexDir);
try {
final Iterator<File> it = FileUtils.iterateFiles(MOVIE_PATH, null, false);
while (it.hasNext()) {
final File file = it.next();
final String id = file.getName().toString();
final String content = FileUtils.readFileToString(file);
logger.info("Indexing document {}", id);
indexer.addDocument(id, content);
}
logger.info("Commiting all pending documents");
indexer.commit();
}
finally {
logger.info("Closing index");
indexer.close();
}
}