use of org.apache.solr.update.AddUpdateCommand in project SearchServices by Alfresco.
the class SolrInformationServer method indexNonShardCascade.
private void indexNonShardCascade(NodeMetaData nodeMetaData) throws IOException {
canUpdate();
SolrQueryRequest request = null;
UpdateRequestProcessor processor = null;
try {
request = getLocalSolrQueryRequest();
processor = this.core.getUpdateProcessingChain(null).createProcessor(request, new SolrQueryResponse());
StringPropertyValue stringPropertyValue = (StringPropertyValue) nodeMetaData.getProperties().get(ContentModel.PROP_CASCADE_TX);
List<FieldInstance> fieldInstances = AlfrescoSolrDataModel.getInstance().getIndexedFieldNamesForProperty(ContentModel.PROP_CASCADE_TX).getFields();
FieldInstance fieldInstance = fieldInstances.get(0);
AddUpdateCommand cmd = new AddUpdateCommand(request);
SolrInputDocument input = new SolrInputDocument();
input.addField(FIELD_SOLR4_ID, AlfrescoSolrDataModel.getNodeDocumentId(nodeMetaData.getTenantDomain(), nodeMetaData.getAclId(), nodeMetaData.getId()));
input.addField(FIELD_VERSION, 0);
input.addField(fieldInstance.getField(), stringPropertyValue.toString());
cmd.solrDoc = input;
processor.processAdd(cmd);
} finally {
if (processor != null) {
processor.finish();
}
if (request != null) {
request.close();
}
}
}
use of org.apache.solr.update.AddUpdateCommand 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