Skip to content

Commit

Permalink
skip parentid if child document is an orphan
Browse files Browse the repository at this point in the history
  • Loading branch information
srgclr authored and martijnvg committed Jan 25, 2017
1 parent 3db53e3 commit 7057bcb
Showing 1 changed file with 4 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,10 @@ public void hitExecute(SearchContext context, HitContext hitContext) {
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) {
Expand Down

0 comments on commit 7057bcb

Please sign in to comment.