|
@@ -62,6 +62,19 @@ public final class IngestDocument {
|
|
|
|
|
|
// Contains all pipelines that have been executed for this document
|
|
|
private final Set<String> executedPipelines = new LinkedHashSet<>();
|
|
|
+
|
|
|
+ /**
|
|
|
+ * An ordered set of the values of the _index that have been used for this document.
|
|
|
+ * <p>
|
|
|
+ * IMPORTANT: This is only updated after a top-level pipeline has run (see {@code IngestService#executePipelines(...)}).
|
|
|
+ * <p>
|
|
|
+ * For example, if a processor changes the _index for a document from 'foo' to 'bar',
|
|
|
+ * and then another processor changes the value back to 'foo', then the overall effect
|
|
|
+ * of the pipeline was that the _index value did not change and so only 'foo' would appear
|
|
|
+ * in the index history.
|
|
|
+ */
|
|
|
+ private Set<String> indexHistory = new LinkedHashSet<>();
|
|
|
+
|
|
|
private boolean doNoSelfReferencesCheck = false;
|
|
|
private boolean reroute = false;
|
|
|
|
|
@@ -70,21 +83,27 @@ public final class IngestDocument {
|
|
|
this.ingestMetadata = new HashMap<>();
|
|
|
this.ingestMetadata.put(TIMESTAMP, ctxMap.getMetadata().getNow());
|
|
|
this.templateModel = initializeTemplateModel();
|
|
|
+
|
|
|
+ // initialize the index history by putting the current index into it
|
|
|
+ this.indexHistory.add(index);
|
|
|
}
|
|
|
|
|
|
+ // note: these rest of these constructors deal with the data-centric view of the IngestDocument, not the execution-centric view.
|
|
|
+ // For example, the copy constructor doesn't populate the `executedPipelines` or `indexHistory` (as well as some other fields),
|
|
|
+ // because those fields are execution-centric.
|
|
|
+
|
|
|
/**
|
|
|
- * Copy constructor that creates a new {@link IngestDocument} which has exactly the same properties as the one provided as argument
|
|
|
+ * Copy constructor that creates a new {@link IngestDocument} which has exactly the same properties as the one provided.
|
|
|
*/
|
|
|
public IngestDocument(IngestDocument other) {
|
|
|
this(
|
|
|
new IngestCtxMap(deepCopyMap(other.ctxMap.getSource()), other.ctxMap.getMetadata().clone()),
|
|
|
deepCopyMap(other.ingestMetadata)
|
|
|
);
|
|
|
- this.reroute = other.reroute;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * Constructor to create an IngestDocument from its constituent maps. The maps are shallow copied.
|
|
|
+ * Constructor to create an IngestDocument from its constituent maps. The maps are shallow copied.
|
|
|
*/
|
|
|
public IngestDocument(Map<String, Object> sourceAndMetadata, Map<String, Object> ingestMetadata) {
|
|
|
Map<String, Object> source;
|
|
@@ -107,7 +126,7 @@ public final class IngestDocument {
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * Constructor to create an IngestDocument from its constituent maps
|
|
|
+ * Constructor to create an IngestDocument from its constituent maps.
|
|
|
*/
|
|
|
IngestDocument(IngestCtxMap ctxMap, Map<String, Object> ingestMetadata) {
|
|
|
this.ctxMap = Objects.requireNonNull(ctxMap);
|
|
@@ -841,6 +860,24 @@ public final class IngestDocument {
|
|
|
return pipelineStack;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * Adds an index to the index history for this document, returning true if the index
|
|
|
+ * was added to the index history (i.e. if it wasn't already in the index history).
|
|
|
+ *
|
|
|
+ * @param index the index to potentially add to the index history
|
|
|
+ * @return true if the index history did not already contain the index in question
|
|
|
+ */
|
|
|
+ public boolean updateIndexHistory(String index) {
|
|
|
+ return indexHistory.add(index);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @return an unmodifiable view of the document's index history
|
|
|
+ */
|
|
|
+ public Set<String> getIndexHistory() {
|
|
|
+ return Collections.unmodifiableSet(indexHistory);
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* @return Whether a self referencing check should be performed
|
|
|
*/
|
|
@@ -990,7 +1027,7 @@ public final class IngestDocument {
|
|
|
/**
|
|
|
* Provides a shallowly read-only, very limited, map-like view of two maps. The only methods that are implemented are
|
|
|
* {@link Map#get(Object)} and {@link Map#containsKey(Object)}, everything else throws UnsupportedOperationException.
|
|
|
- *
|
|
|
+ * <p>
|
|
|
* The overrides map has higher priority than the primary map -- values in that map under some key will take priority over values
|
|
|
* in the primary map under the same key.
|
|
|
*
|