use of org.apache.solr.update.processor.UpdateRequestProcessor in project SearchServices by Alfresco.
the class SolrInformationServer method updateContentToIndexAndCache.
@Override
public void updateContentToIndexAndCache(long dbId, String tenant) throws Exception {
SolrQueryRequest request = null;
UpdateRequestProcessor processor = null;
try {
if (!spinLock(dbId, 120000)) {
throw new Exception("Unable to acquire spinlock for node:" + dbId);
}
request = getLocalSolrQueryRequest();
processor = this.core.getUpdateProcessingChain(null).createProcessor(request, new SolrQueryResponse());
SolrInputDocument doc = solrContentStore.retrieveDocFromSolrContentStore(tenant, dbId);
if (doc == null) {
log.warn("There is no cached doc in the Solr content store with tenant [" + tenant + "] and dbId [" + dbId + "].\n" + "This should only happen if the content has been removed from the Solr content store.\n" + "Recreating cached doc ... ");
doc = recreateSolrDoc(dbId, tenant);
// This is a work around for ACE-3228/ACE-3258 and the way stores are expunged when deleting a tenant
if (doc == null) {
deleteNode(processor, request, dbId);
}
}
if (doc != null) {
addContentToDoc(doc, dbId);
// Marks as clean since the doc's content is now up to date
markFTSStatus(doc, FTSStatus.Clean);
solrContentStore.storeDocOnSolrContentStore(tenant, dbId, doc);
// Add to index
AddUpdateCommand addDocCmd = new AddUpdateCommand(request);
addDocCmd.overwrite = true;
addDocCmd.solrDoc = doc;
// System.out.println("############# indexing content:"+doc);
processor.processAdd(addDocCmd);
}
} finally {
unlock(dbId);
if (processor != null) {
processor.finish();
}
if (request != null) {
request.close();
}
}
}
Aggregations