Search in sources :

Example 6 with QuestionItemDocumentFactory

use of org.olat.modules.qpool.manager.QuestionItemDocumentFactory in project openolat by klemens.

the class QuestionItemIndexer method fullIndex.

@Override
public void fullIndex(LifeFullIndexer indexWriter) {
    QPoolService qpoolService = CoreSpringFactory.getImpl(QPoolService.class);
    QuestionItemDocumentFactory docFactory = CoreSpringFactory.getImpl(QuestionItemDocumentFactory.class);
    SearchResourceContext ctxt = new SearchResourceContext();
    IndexWriter writer = null;
    try {
        writer = indexWriter.getAndLockWriter();
        int counter = 0;
        List<QuestionItemFull> items;
        do {
            items = qpoolService.getAllItems(counter, BATCH_SIZE);
            for (QuestionItemFull item : items) {
                Document doc = docFactory.createDocument(ctxt, item);
                indexWriter.addDocument(doc, writer);
            }
            counter += items.size();
        } while (items.size() == BATCH_SIZE);
    } catch (Exception e) {
        log.error("", e);
    } finally {
        indexWriter.releaseWriter(writer);
    }
}
Also used : QuestionItemDocumentFactory(org.olat.modules.qpool.manager.QuestionItemDocumentFactory) QuestionItemFull(org.olat.modules.qpool.QuestionItemFull) QPoolService(org.olat.modules.qpool.QPoolService) SearchResourceContext(org.olat.search.service.SearchResourceContext) IndexWriter(org.apache.lucene.index.IndexWriter) Document(org.apache.lucene.document.Document) QItemDocument(org.olat.modules.qpool.model.QItemDocument)

Aggregations

QuestionItemDocumentFactory (org.olat.modules.qpool.manager.QuestionItemDocumentFactory)6 Document (org.apache.lucene.document.Document)4 QItemDocument (org.olat.modules.qpool.model.QItemDocument)4 SearchResourceContext (org.olat.search.service.SearchResourceContext)4 ArrayList (java.util.ArrayList)2 IndexWriter (org.apache.lucene.index.IndexWriter)2 QPoolService (org.olat.modules.qpool.QPoolService)2 QuestionItemFull (org.olat.modules.qpool.QuestionItemFull)2