diff --git a/server/src/main/java/org/opensearch/index/engine/Engine.java b/server/src/main/java/org/opensearch/index/engine/Engine.java index 1d163f65313ca..f11e581e7c725 100644 --- a/server/src/main/java/org/opensearch/index/engine/Engine.java +++ b/server/src/main/java/org/opensearch/index/engine/Engine.java @@ -479,6 +479,7 @@ public abstract static class Result { private final SetOnce freeze = new SetOnce<>(); private final Mapping requiredMappingUpdate; private Translog.Location translogLocation; + private InternalEngine.IndexingStrategy indexingStrategy; private long took; protected Result(Operation.TYPE operationType, Exception failure, long version, long term, long seqNo) { @@ -492,6 +493,10 @@ protected Result(Operation.TYPE operationType, Exception failure, long version, } protected Result(Operation.TYPE operationType, long version, long term, long seqNo) { + this(operationType, version, term, seqNo, null); + } + + protected Result(Operation.TYPE operationType, long version, long term, long seqNo, InternalEngine.IndexingStrategy indexingStrategy) { this.operationType = operationType; this.version = version; this.seqNo = seqNo; @@ -604,6 +609,11 @@ public static class IndexResult extends Result { private final boolean created; + public IndexResult(long version, long term, long seqNo, boolean created, InternalEngine.IndexingStrategy plan) { + super(Operation.TYPE.INDEX, version, term, seqNo, plan); + this.created = created; + } + public IndexResult(long version, long term, long seqNo, boolean created) { super(Operation.TYPE.INDEX, version, term, seqNo); this.created = created; diff --git a/server/src/main/java/org/opensearch/index/engine/InternalEngine.java b/server/src/main/java/org/opensearch/index/engine/InternalEngine.java index 51c0974342341..607ebff44d239 100644 --- a/server/src/main/java/org/opensearch/index/engine/InternalEngine.java +++ b/server/src/main/java/org/opensearch/index/engine/InternalEngine.java @@ -1130,7 +1130,7 @@ private IndexResult indexIntoLucene(Index index, IndexingStrategy plan) throws I assert assertDocDoesNotExist(index, canOptimizeAddDocument(index) == false); addDocs(index.docs(), indexWriter); } - return new IndexResult(plan.versionForIndexing, index.primaryTerm(), index.seqNo(), plan.currentNotFoundOrDeleted); + return new IndexResult(plan.versionForIndexing, index.primaryTerm(), index.seqNo(), plan.currentNotFoundOrDeleted, plan); } catch (Exception ex) { if (ex instanceof AlreadyClosedException == false && indexWriter.getTragicException() == null