Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
- Fix `cluster.remote.<cluster_alias>.server_name` setting no populating SNI ([#20321](https://github.com/opensearch-project/OpenSearch/pull/20321))
- Fix X-Opaque-Id header propagation (along with other response headers) for streaming Reactor Netty 4 transport ([#20371](https://github.com/opensearch-project/OpenSearch/pull/20371))
- Fix indexing regression and bug fixes for grouping criteria. ([20145](https://github.com/opensearch-project/OpenSearch/pull/20145))
- LeafReader should not remove SubReaderWrappers incase IndexWriter encounters a non aborting Exception ([#20193](https://github.com/opensearch-project/OpenSearch/pull/20193))

### Dependencies
- Bump `com.google.auth:google-auth-library-oauth2-http` from 1.38.0 to 1.41.0 ([#20183](https://github.com/opensearch-project/OpenSearch/pull/20183))
Expand Down
27 changes: 26 additions & 1 deletion server/src/main/java/org/opensearch/common/lucene/Lucene.java
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@
import org.opensearch.ExceptionsHelper;
import org.opensearch.common.Nullable;
import org.opensearch.common.SuppressForbidden;
import org.opensearch.common.lucene.index.DerivedSourceLeafReader;
import org.opensearch.common.lucene.search.TopDocsAndMaxScore;
import org.opensearch.common.util.iterable.Iterables;
import org.opensearch.core.common.Strings;
Expand Down Expand Up @@ -951,12 +952,36 @@ public LeafReader wrap(LeafReader leaf) {
}

assert numDocs == popCount(hardLiveDocs) : numDocs + " != " + popCount(hardLiveDocs);
return new LeafReaderWithLiveDocs(segmentReader, hardLiveDocs, numDocs);
if (isDerivedSourceEnabled(leaf)) {
return new LeafReaderWithLiveDocs(leaf, hardLiveDocs, numDocs);
} else {
return new LeafReaderWithLiveDocs(segmentReader, hardLiveDocs, numDocs);
}
}

private boolean isContextAwareEnabled(SegmentReader reader) {
return reader.getSegmentInfo().info.getAttribute(CriteriaBasedCodec.BUCKET_NAME) != null;
}

/**
* A FilterCodecReader can never accept a DerivedSourceLeafReader as a delegate as it is IndexReader.
* DerivedSourceLeafReader can be wrapped up by only FilterLeafReader.
* @param reader the underlying leafReader.
*
* @return whether derived source is enabled or not.
*/
public boolean isDerivedSourceEnabled(LeafReader reader) {
if (reader instanceof SegmentReader) {
return false;
} else if (reader instanceof DerivedSourceLeafReader) {
return true;
} else if (reader instanceof FilterLeafReader) {
FilterLeafReader filterLeafReader = (FilterLeafReader) reader;
return isDerivedSourceEnabled(filterLeafReader.getDelegate());
}

return false;
}
});
}

Expand Down
Loading
Loading