Skip to content

Commit

Permalink
added comments and added null checks in the case the filter return null
Browse files Browse the repository at this point in the history
  • Loading branch information
martijnvg committed Apr 21, 2015
1 parent 4f3fa20 commit 3687d9b
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
Expand Up @@ -544,7 +544,9 @@ public ObjectMapper findNestedObjectMapper(int nestedDocId, SearchContext sc, Le
if (filter == null) {
continue;
}
DocIdSet nestedTypeSet = filter.getDocIdSet(context, context.reader().getLiveDocs());
// We can pass down 'null' as acceptedDocs, because nestedDocId is a doc to be fetched and
// therefor is guaranteed to be a live doc.
DocIdSet nestedTypeSet = filter.getDocIdSet(context, null);
DocIdSetIterator iterator = nestedTypeSet.iterator();
if (iterator.advance(nestedDocId) == nestedDocId) {
if (nestedObjectMapper == null) {
Expand Down
12 changes: 11 additions & 1 deletion src/main/java/org/elasticsearch/search/fetch/FetchPhase.java
Expand Up @@ -391,8 +391,18 @@ private InternalSearchHit.InternalNestedIdentity getInternalNestedIdentity(Searc
BitSet parentBits = parentBitSet.bits();
int offset = 0;
Filter childFilter = context.filterCache().cache(nestedObjectMapper.nestedTypeFilter(), null, context.queryParserService().autoFilterCachePolicy());
DocIdSet childDocSet = childFilter.getDocIdSet(subReaderContext, subReaderContext.reader().getLiveDocs());
if (childFilter == null) {
continue;
}
// We can pass down 'null' as acceptedDocs, because we're fetching matched docId that matched in the query phase.
DocIdSet childDocSet = childFilter.getDocIdSet(subReaderContext, null);
if (childDocSet == null) {
continue;
}
DocIdSetIterator childIter = childDocSet.iterator();
if (childIter == null) {
continue;
}
int nextParent = parentBits.nextSetBit(currentParent);
for (int docId = childIter.advance(currentParent + 1); docId < nextParent && docId != DocIdSetIterator.NO_MORE_DOCS; docId = childIter.nextDoc()) {
offset++;
Expand Down

0 comments on commit 3687d9b

Please sign in to comment.