Skip to content

Commit 40334db

Browse files
committed
Iter
1 parent ed6f965 commit 40334db

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

server/src/main/java/org/elasticsearch/index/mapper/DocumentParserContext.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -672,6 +672,7 @@ public final DocumentParserContext createNestedContext(NestedObjectMapper nested
672672
// parent document's _id is not yet available.
673673
// So we just add the child document without the parent _id, then in TimeSeriesIdFieldMapper#postParse we set the _id on all
674674
// child documents once we've calculated it.
675+
assert getRoutingFields().equals(RoutingFields.Noop.INSTANCE) == false;
675676
} else {
676677
throw new IllegalStateException("The root document of a nested document should have an _id field");
677678
}

server/src/main/java/org/elasticsearch/index/mapper/TimeSeriesIdFieldMapper.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -146,11 +146,12 @@ public void postParse(DocumentParserContext context) throws IOException {
146146
);
147147

148148
// We need to add the uid or id to nested Lucene documents so that when a document gets deleted, the nested documents are
149-
// also deleted. Usually this happens when the nested document is created (in DocumentParser#createNestedContext), but
149+
// also deleted. Usually this happens when the nested document is created (in DocumentParserContext#createNestedContext), but
150150
// for time-series indices the _id isn't available at that point.
151-
assert context.id() != null;
151+
var binaryId = context.doc().getField(IdFieldMapper.NAME).binaryValue();
152152
for (LuceneDocument doc : context.nonRootDocuments()) {
153-
doc.add(new StringField(IdFieldMapper.NAME, Uid.encodeId(context.id()), Field.Store.NO));
153+
assert doc.getField(IdFieldMapper.NAME) == null;
154+
doc.add(new StringField(IdFieldMapper.NAME, binaryId, Field.Store.NO));
154155
}
155156
}
156157

0 commit comments

Comments
 (0)