skip parentid if child document is an orphan

#22770
This commit is contained in:
srgclr 2017-01-24 17:49:53 +00:00 committed by GitHub
parent f0f75b187a
commit 93a28b0acf
1 changed files with 4 additions and 0 deletions

View File

@ -63,6 +63,10 @@ public final class ParentFieldSubFetchPhase implements FetchSubPhase {
public static String getParentId(ParentFieldMapper fieldMapper, LeafReader reader, int docId) {
try {
SortedDocValues docValues = reader.getSortedDocValues(fieldMapper.name());
if (docValues == null) {
// hit has no _parent field.
return null;
}
BytesRef parentId = docValues.get(docId);
return parentId.length > 0 ? parentId.utf8ToString() : null;
} catch (IOException e) {