Package org.apache.solr.update.processor
Class AtomicUpdateDocumentMerger
- java.lang.Object
-
- org.apache.solr.update.processor.AtomicUpdateDocumentMerger
-
public class AtomicUpdateDocumentMerger extends Object
- WARNING: This API is experimental and might change in incompatible ways in the next release.
-
-
Field Summary
Fields Modifier and Type Field Description protected SchemaFieldidFieldprotected IndexSchemaschema
-
Constructor Summary
Constructors Constructor Description AtomicUpdateDocumentMerger(SolrQueryRequest queryReq)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static Set<String>computeInPlaceUpdatableFields(AddUpdateCommand cmd)Given an add update command, compute a list of fields that can be updated in-place.protected voiddoAdd(SolrInputDocument toDoc, SolrInputField sif, Object fieldVal)protected voiddoAddDistinct(SolrInputDocument toDoc, SolrInputField sif, Object fieldVal)protected voiddoInc(SolrInputDocument toDoc, SolrInputField sif, Object fieldVal)booleandoInPlaceUpdateMerge(AddUpdateCommand cmd, Set<String> updatedFields)Given an AddUpdateCommand containing update operations (e.g.protected voiddoRemove(SolrInputDocument toDoc, SolrInputField sif, Object fieldVal)protected voiddoRemoveRegex(SolrInputDocument toDoc, SolrInputField sif, Object valuePatterns)protected voiddoSet(SolrInputDocument toDoc, SolrInputField sif, Object fieldVal)static SolrInputFieldgetFieldFromHierarchy(SolrInputDocument completeHierarchy, String fieldPath)static booleanisAtomicUpdate(AddUpdateCommand cmd)Utility method that examines the SolrInputDocument in an AddUpdateCommand and returns true if the documents contains atomic update instructions.static booleanisDerivedFromDoc(SolrInputDocument fullDoc, SolrInputDocument partialDoc)static booleanisSupportedFieldForInPlaceUpdate(SchemaField schemaField)Given a schema field, return whether or not such a field is supported for an in-place update.SolrInputDocumentmerge(SolrInputDocument fromDoc, SolrInputDocument toDoc)Merges the fromDoc into the toDoc using the atomic update syntax.SolrInputDocumentmergeChildDoc(SolrInputDocument sdoc, SolrInputDocument oldDocWithChildren, SolrInputDocument sdocWithChildren)Merges an Atomic Update inside a document hierarchySolrInputDocumentupdateDocInSif(SolrInputField updateSif, SolrInputDocument cmdDocWChildren, SolrInputDocument updateDoc)
-
-
-
Field Detail
-
schema
protected final IndexSchema schema
-
idField
protected final SchemaField idField
-
-
Constructor Detail
-
AtomicUpdateDocumentMerger
public AtomicUpdateDocumentMerger(SolrQueryRequest queryReq)
-
-
Method Detail
-
isAtomicUpdate
public static boolean isAtomicUpdate(AddUpdateCommand cmd)
Utility method that examines the SolrInputDocument in an AddUpdateCommand and returns true if the documents contains atomic update instructions.
-
merge
public SolrInputDocument merge(SolrInputDocument fromDoc, SolrInputDocument toDoc)
Merges the fromDoc into the toDoc using the atomic update syntax.- Parameters:
fromDoc- SolrInputDocument which will merged into the toDoctoDoc- the final SolrInputDocument that will be mutated with the values from the fromDoc atomic commands- Returns:
- toDoc with mutated values
-
isSupportedFieldForInPlaceUpdate
public static boolean isSupportedFieldForInPlaceUpdate(SchemaField schemaField)
Given a schema field, return whether or not such a field is supported for an in-place update. Note: If an update command has updates to only supported fields (and _version_ is also supported), only then is such an update command executed as an in-place update.
-
computeInPlaceUpdatableFields
public static Set<String> computeInPlaceUpdatableFields(AddUpdateCommand cmd) throws IOException
Given an add update command, compute a list of fields that can be updated in-place. If there is even a single field in the update that cannot be updated in-place, the entire update cannot be executed in-place (and empty set will be returned in that case).- Returns:
- Return a set of fields that can be in-place updated.
- Throws:
IOException
-
isDerivedFromDoc
public static boolean isDerivedFromDoc(SolrInputDocument fullDoc, SolrInputDocument partialDoc)
- Parameters:
fullDoc- the full doc to be compared againstpartialDoc- the sub document to be tested- Returns:
- whether partialDoc is derived from fullDoc
-
getFieldFromHierarchy
public static SolrInputField getFieldFromHierarchy(SolrInputDocument completeHierarchy, String fieldPath)
- Parameters:
completeHierarchy- SolrInputDocument that represents the nested document hierarchy from its rootfieldPath- the path to fetch, seperated by a '/' e.g. /children/grandChildren- Returns:
- the SolrInputField of fieldPath
-
doInPlaceUpdateMerge
public boolean doInPlaceUpdateMerge(AddUpdateCommand cmd, Set<String> updatedFields) throws IOException
Given an AddUpdateCommand containing update operations (e.g. set, inc), merge and resolve the operations into a partial document that can be used for indexing the in-place updates. The AddUpdateCommand is modified to contain the partial document (instead of the original document which contained the update operations) and also the prevVersion that this in-place update depends on. Note: updatedFields passed into the method can be changed, i.e. the version field can be added to the set.- Returns:
- If in-place update cannot succeed, e.g. if the old document is deleted recently, then false is returned. A false return indicates that this update can be re-tried as a full atomic update. Returns true if the in-place update succeeds.
- Throws:
IOException
-
mergeChildDoc
public SolrInputDocument mergeChildDoc(SolrInputDocument sdoc, SolrInputDocument oldDocWithChildren, SolrInputDocument sdocWithChildren)
Merges an Atomic Update inside a document hierarchy- Parameters:
sdoc- the doc containing update instructionsoldDocWithChildren- the doc (children included) before the updatesdocWithChildren- the updated doc prior to the update (children included)- Returns:
- root doc (children included) after update
-
updateDocInSif
public SolrInputDocument updateDocInSif(SolrInputField updateSif, SolrInputDocument cmdDocWChildren, SolrInputDocument updateDoc)
- Parameters:
updateSif- the SolrInputField to update its valuescmdDocWChildren- the doc to insert/set inside updateSifupdateDoc- the document that was sent as part of the Add Update Command- Returns:
- updated SolrInputDocument
-
doSet
protected void doSet(SolrInputDocument toDoc, SolrInputField sif, Object fieldVal)
-
doAdd
protected void doAdd(SolrInputDocument toDoc, SolrInputField sif, Object fieldVal)
-
doAddDistinct
protected void doAddDistinct(SolrInputDocument toDoc, SolrInputField sif, Object fieldVal)
-
doInc
protected void doInc(SolrInputDocument toDoc, SolrInputField sif, Object fieldVal)
-
doRemove
protected void doRemove(SolrInputDocument toDoc, SolrInputField sif, Object fieldVal)
-
doRemoveRegex
protected void doRemoveRegex(SolrInputDocument toDoc, SolrInputField sif, Object valuePatterns)
-
-