Hello all,
I am using solr 5.5 and I am trying to use
StatelessScriptUpdateProcessorFactory to append the data I am adding to solr to
existing documents. This is working fine when I use one shard but it doesn't
work on multiple shards.
Is there any way to use it with multiple shards?
This is the updateProcessor.js:
function processAdd(cmd) {
logger.error(" >> processAdd")
var name="";
var startDate="";
var dataCurr="";
doc = cmd.solrDoc;
var previousDoc=null;
var previousData="";
nameDoc=doc.getField("name");
if( nameDoc !=null ){
name=doc.getFieldValue("name").toString();
startDate= doc.getFieldValue("start_date_s").toString();
dataCurr=doc.getFieldValue("data_ws").toString();
}
try{
var Term = Java.type("org.apache.lucene.index.Term");
previousDocId= req.getSearcher().getFirstMatch(new
Term("id",name+"_"+startDate));
previousDoc=req.getSearcher().doc(previousDocId);
previousData= previousDoc.getField("data_ws").stringValue();
doc.setField("data_ws",previousData+dataCurr);
}
catch(err){
logger.error("error in update processor "+err)
}
doc.setField("id",name+"_"+startDate);
}
function processDelete(cmd) {
// no-op
}
function processMergeIndexes(cmd) {
// no-op
}
function processCommit(cmd) {
// no-op
}
function processRollback(cmd) {
// no-op
}
function finish() {
// no-op
}
Thanks and Regards,
Giannis