Skip to content

Commit 93a28b0

Browse files
authored
skip parentid if child document is an orphan
elastic#22770
1 parent f0f75b1 commit 93a28b0

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

core/src/main/java/org/elasticsearch/search/fetch/subphase/ParentFieldSubFetchPhase.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,10 @@ public void hitExecute(SearchContext context, HitContext hitContext) {
6363
public static String getParentId(ParentFieldMapper fieldMapper, LeafReader reader, int docId) {
6464
try {
6565
SortedDocValues docValues = reader.getSortedDocValues(fieldMapper.name());
66+
if (docValues == null) {
67+
// hit has no _parent field.
68+
return null;
69+
}
6670
BytesRef parentId = docValues.get(docId);
6771
return parentId.length > 0 ? parentId.utf8ToString() : null;
6872
} catch (IOException e) {

0 commit comments

Comments
 (0)