fix ShardUtils#getElasticsearchDirectoryReader(...) to use FilterDirectoryReader#getDelegate()

This commit is contained in:
Martijn van Groningen 2015-08-03 09:54:56 +02:00
parent ac2e0fd6a0
commit 50c345238b
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;