Search in sources :

Example 1 with SearchService

use of org.olat.search.SearchService in project OpenOLAT by OpenOLAT.

the class SearchIndexingJob method interrupt.

@Override
public void interrupt() throws UnableToInterruptJobException {
    log.info("Interrupt indexer via quartz.");
    SearchService searchService = SearchServiceFactory.getService();
    if (searchService instanceof SearchServiceImpl) {
        ((SearchServiceImpl) searchService).getInternalIndexer().stopFullIndex();
    }
}
Also used : SearchService(org.olat.search.SearchService) SearchServiceImpl(org.olat.search.service.SearchServiceImpl)

Example 2 with SearchService

use of org.olat.search.SearchService in project OpenOLAT by OpenOLAT.

the class FileDocumentFactory method getDocumentFromCurrentIndex.

private Document getDocumentFromCurrentIndex(SearchResourceContext leafResourceContext, VFSLeaf leaf) {
    try {
        String resourceUrl = leafResourceContext.getResourceUrl();
        SearchService searchService = CoreSpringFactory.getImpl(SearchServiceImpl.class);
        Document indexedDoc = searchService.doSearch(resourceUrl);
        if (indexedDoc != null) {
            String timestamp = indexedDoc.get(AbstractOlatDocument.TIME_STAMP_NAME);
            if (timestamp != null) {
                Date indexLastModification = DateTools.stringToDate(timestamp);
                Date docLastModificationDate = new Date(leaf.getLastModified());
                if (leaf instanceof MetaTagged) {
                    MetaInfo metaInfo = ((MetaTagged) leaf).getMetaInfo();
                    Date metaDate = metaInfo.getMetaLastModified();
                    if (metaDate != null && metaDate.after(docLastModificationDate)) {
                        docLastModificationDate = metaDate;
                    }
                }
                if (docLastModificationDate.compareTo(indexLastModification) < 0) {
                    OlatDocument olatDoc = new OlatDocument(indexedDoc);
                    return olatDoc.getLuceneDocument();
                }
            }
        }
    } catch (ServiceNotAvailableException | ParseException | QueryException | java.text.ParseException e) {
        log.error("", e);
    }
    return null;
}
Also used : ServiceNotAvailableException(org.olat.search.ServiceNotAvailableException) AbstractOlatDocument(org.olat.search.model.AbstractOlatDocument) OlatDocument(org.olat.search.model.OlatDocument) QueryException(org.olat.search.QueryException) SearchService(org.olat.search.SearchService) MetaTagged(org.olat.core.commons.modules.bc.meta.tagged.MetaTagged) MetaInfo(org.olat.core.commons.modules.bc.meta.MetaInfo) ParseException(org.apache.lucene.queryparser.classic.ParseException) Document(org.apache.lucene.document.Document) AbstractOlatDocument(org.olat.search.model.AbstractOlatDocument) OlatDocument(org.olat.search.model.OlatDocument) Date(java.util.Date)

Example 3 with SearchService

use of org.olat.search.SearchService in project OpenOLAT by OpenOLAT.

the class SearchIndexingJob method executeWithDB.

/**
 * @see org.olat.core.commons.services.scheduler.JobWithDB#executeWithDB(org.quartz.JobExecutionContext)
 */
@Override
public void executeWithDB(JobExecutionContext arg0) throws JobExecutionException {
    log.info("Search indexer started via cronjob.");
    SearchService searchService = SearchServiceFactory.getService();
    if (searchService instanceof SearchServiceImpl) {
        ((SearchServiceImpl) searchService).getInternalIndexer().startFullIndex();
    }
}
Also used : SearchService(org.olat.search.SearchService) SearchServiceImpl(org.olat.search.service.SearchServiceImpl)

Example 4 with SearchService

use of org.olat.search.SearchService in project openolat by klemens.

the class SearchIndexingJob method executeWithDB.

/**
 * @see org.olat.core.commons.services.scheduler.JobWithDB#executeWithDB(org.quartz.JobExecutionContext)
 */
@Override
public void executeWithDB(JobExecutionContext arg0) throws JobExecutionException {
    log.info("Search indexer started via cronjob.");
    SearchService searchService = SearchServiceFactory.getService();
    if (searchService instanceof SearchServiceImpl) {
        ((SearchServiceImpl) searchService).getInternalIndexer().startFullIndex();
    }
}
Also used : SearchService(org.olat.search.SearchService) SearchServiceImpl(org.olat.search.service.SearchServiceImpl)

Example 5 with SearchService

use of org.olat.search.SearchService in project openolat by klemens.

the class SearchIndexingJob method interrupt.

@Override
public void interrupt() throws UnableToInterruptJobException {
    log.info("Interrupt indexer via quartz.");
    SearchService searchService = SearchServiceFactory.getService();
    if (searchService instanceof SearchServiceImpl) {
        ((SearchServiceImpl) searchService).getInternalIndexer().stopFullIndex();
    }
}
Also used : SearchService(org.olat.search.SearchService) SearchServiceImpl(org.olat.search.service.SearchServiceImpl)

Aggregations

SearchService (org.olat.search.SearchService)6 SearchServiceImpl (org.olat.search.service.SearchServiceImpl)4 Date (java.util.Date)2 Document (org.apache.lucene.document.Document)2 ParseException (org.apache.lucene.queryparser.classic.ParseException)2 MetaInfo (org.olat.core.commons.modules.bc.meta.MetaInfo)2 MetaTagged (org.olat.core.commons.modules.bc.meta.tagged.MetaTagged)2 QueryException (org.olat.search.QueryException)2 ServiceNotAvailableException (org.olat.search.ServiceNotAvailableException)2 AbstractOlatDocument (org.olat.search.model.AbstractOlatDocument)2 OlatDocument (org.olat.search.model.OlatDocument)2