/** * Takes docs from the repository and indexes them. This has to be done only once * * @throws IOException * @throws LockObtainFailedException * @throws CorruptIndexException */ public void indexDocs(String collection) throws CorruptIndexException, LockObtainFailedException, IOException { dir = new RAMDirectory(); IndexWriterConfig config = new IndexWriterConfig(Version.LUCENE_40, analyzer); IndexWriter writer = new IndexWriter(dir, config); for (DBCursor it = repo.retrieveDocs(collection); it.hasNext(); ) { logger.info("added doc"); addDoc(writer, it.next()); } writer.close(); }
@Scheduled(fixedDelay = 300000) public void indexDocs() throws CorruptIndexException, LockObtainFailedException, IOException { String collection = DocStore.CIVIC_COMMONS_COLLECTION; dir = new RAMDirectory(); IndexWriterConfig config = new IndexWriterConfig(Version.LUCENE_40, analyzer); IndexWriter writer = new IndexWriter(dir, config); DBCursor it = repo.retrieveDocs(collection); while (it.hasNext()) { logger.info("added doc from scheduler"); addDoc(writer, it.next()); } writer.close(); }