I thought about next solution for the my problem: Atomic Update + Replicas.
I can set my *UpdateProcessorsChain* in the next order:
<MergerUpdateProcessor/>
<CustomUpdateProcessor-1/>
. . .
<CustomUpdateProcessor-n/>
<DistributedUpdateProcessor>
<RunUpdateProcessor/>
MergerUpdateProcessor will use getUpdatedDocument function of
DistibutedUpdateProcessor
<https://github.com/apache/lucene-solr/blob/master/solr/core/src/java/org/apache/solr/update/processor/DistributedUpdateProcessor.java>
.
/ public void processAdd(AddUpdateCommand cmd) {
if (!AtomicUpdateDocumentMerger.isAtomicUpdate(cmd)) {
*super.processAdd(cmd);
return;*
}
*AtomicUpdateDocumentMerger docMerger = new
AtomicUpdateDocumentMerger(cmd.getReq);*
Set<String> inPlaceUpdatedFields =
AtomicUpdateDocumentMerger.computeInPlaceUpdatableFields(cmd);
if (inPlaceUpdatedFields.size() > 0) { // non-empty means this is
suitable for in-place updates
if (docMerger.doInPlaceUpdateMerge(cmd, inPlaceUpdatedFields)) {
*super.processAdd(cmd);
return;*
} else {
// in-place update failed, so fall through and re-try the same with
a full atomic update
}
}
// full (non-inplace) atomic update
SolrInputDocument sdoc = cmd.getSolrInputDocument();
BytesRef id = cmd.getIndexedId();
SolrInputDocument oldDoc =
RealTimeGetComponent.getInputDocument(cmd.getReq().getCore(), id);
if (oldDoc == null) {
// create a new doc by default if an old one wasn't found
if (*cmd.getVersion()* <= 0) {
oldDoc = new SolrInputDocument();
} else {
// could just let the optimistic locking throw the error
throw new SolrException(ErrorCode.CONFLICT, "Document not found for
update. id=" + cmd.getPrintableId());
}
} else {
oldDoc.remove(CommonParams.VERSION_FIELD);
}
cmd.solrDoc = docMerger.merge(sdoc, oldDoc);
*super.processAdd(cmd);*
}/
What do you think about my solution (all changes in source code are marked
in bold)? I checked it in my test environment, and it worked fine. Maybe do
I miss something? Edge cases?
--
Sent from: http://lucene.472066.n3.nabble.com/Solr-User-f472068.html