Merge pull request #12594 from martijnvg/ShardUtils#getElasticsearchDirectoryReader

Fix ShardUtils#getElasticsearchDirectoryReader()
This commit is contained in:
Martijn van Groningen 2015-08-03 10:27:53 +02:00
commit c76a279b31
1 changed files with 5 additions and 1 deletions

View File

@ -78,7 +78,11 @@ public final class ShardUtils {
if (reader instanceof ElasticsearchDirectoryReader) {
return (ElasticsearchDirectoryReader) reader;
} else {
return null; // lucene needs a getDelegate method on FilteredDirectoryReader - not a big deal here
// We need to use FilterDirectoryReader#getDelegate and not FilterDirectoryReader#unwrap, because
// If there are multiple levels of filtered leaf readers then with the unwrap() method it immediately
// returns the most inner leaf reader and thus skipping of over any other filtered leaf reader that
// may be instance of ElasticsearchLeafReader. This can cause us to miss the shardId.
return getElasticsearchDirectoryReader(((FilterDirectoryReader) reader).getDelegate());
}
}
return null;