Skip to content

Commit df46482

Browse files
committed
Merge branch 'main' into extend-classpath-plugins
2 parents 5e4f843 + bf8cd25 commit df46482

File tree

10 files changed

+35
-8
lines changed

10 files changed

+35
-8
lines changed

CHANGELOG.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
1515
- [Security Manager Replacement] Enhance Java Agent to intercept newByteChannel ([#17989](https://github.com/opensearch-project/OpenSearch/pull/17989))
1616
- Enabled Async Shard Batch Fetch by default ([#18139](https://github.com/opensearch-project/OpenSearch/pull/18139))
1717
- Allow to get the search request from the QueryCoordinatorContext ([#17818](https://github.com/opensearch-project/OpenSearch/pull/17818))
18+
- Improve sort-query performance by retaining the default `totalHitsThreshold` for approximated `match_all` queries ([#18189](https://github.com/opensearch-project/OpenSearch/pull/18189))
1819
- Enable testing for ExtensiblePlugins using classpath plugins ([#16908](https://github.com/opensearch-project/OpenSearch/pull/16908))
1920

2021
### Changed
@@ -26,6 +27,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
2627
- Update Apache HttpClient5 and HttpCore5 (CVE-2025-27820) ([#18152](https://github.com/opensearch-project/OpenSearch/pull/18152))
2728
- Bump `org.apache.commons:commons-collections4` from 4.4 to 4.5.0 ([#18101](https://github.com/opensearch-project/OpenSearch/pull/18101))
2829
- Bump `netty` from 4.1.118.Final to 4.1.121.Final ([#18192](https://github.com/opensearch-project/OpenSearch/pull/18192))
30+
- Bump `org.apache.commons:commons-configuration2` from 2.11.0 to 2.12.0 ([#18103](https://github.com/opensearch-project/OpenSearch/pull/18103))
2931

3032
### Deprecated
3133

@@ -36,8 +38,9 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
3638
- Remove package org.opensearch.transport.grpc and replace with org.opensearch.plugin.transport.grpc ([#18031](https://github.com/opensearch-project/OpenSearch/pull/18031))
3739
- Fix the native plugin installation error cause by the pgp public key change ([#18147](https://github.com/opensearch-project/OpenSearch/pull/18147))
3840
- Fix object field exists query ([#17843](https://github.com/opensearch-project/OpenSearch/pull/17843))
39-
- Use Bad Request status for InputCoercionEcception ([#18161](https://github.com/opensearch-project/OpenSearch/pull/18161))
41+
- Use Bad Request status for InputCoercionException ([#18161](https://github.com/opensearch-project/OpenSearch/pull/18161))
4042
- Null check field names in QueryStringQueryBuilder ([#18194](https://github.com/opensearch-project/OpenSearch/pull/18194))
43+
- Avoid NPE if on SnapshotInfo if 'shallow' boolean not present ([#18187](https://github.com/opensearch-project/OpenSearch/issues/18187))
4144

4245
### Security
4346

plugins/repository-hdfs/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ dependencies {
7474
api "commons-codec:commons-codec:${versions.commonscodec}"
7575
api 'commons-collections:commons-collections:3.2.2'
7676
api "org.apache.commons:commons-compress:${versions.commonscompress}"
77-
api 'org.apache.commons:commons-configuration2:2.11.0'
77+
api 'org.apache.commons:commons-configuration2:2.12.0'
7878
api "commons-io:commons-io:${versions.commonsio}"
7979
api 'org.apache.commons:commons-lang3:3.17.0'
8080
implementation 'com.google.re2j:re2j:1.8'

plugins/repository-hdfs/licenses/commons-configuration2-2.11.0.jar.sha1

Lines changed: 0 additions & 1 deletion
This file was deleted.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
0cab81350c85ca35db8c47621a19dcddf128883f

server/src/internalClusterTest/java/org/opensearch/search/sort/FieldSortIT.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1145,7 +1145,7 @@ public void testSortMissingNumbersMinMax() throws Exception {
11451145
.get();
11461146
assertNoFailures(searchResponse);
11471147

1148-
assertThat(searchResponse.getHits().getTotalHits().value(), equalTo(2L));
1148+
assertThat(searchResponse.getHits().getTotalHits().value(), equalTo(3L));
11491149
assertThat(searchResponse.getHits().getAt(0).getId(), equalTo("1"));
11501150
// The order here could be unstable (depends on document order) since missing == field value
11511151
assertThat(searchResponse.getHits().getAt(1).getId(), is(oneOf("3", "2")));

server/src/main/java/org/opensearch/repositories/blobstore/BlobStoreRepository.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4568,7 +4568,7 @@ public IndexShardSnapshot loadShardSnapshot(BlobContainer shardContainer, Snapsh
45684568
SnapshotId snapshotId = snapshotInfo.snapshotId();
45694569
if (snapshotInfo.getPinnedTimestamp() != 0) {
45704570
return () -> IndexShardSnapshotStatus.newDone(0L, 0L, 0, 0, 0, 0, "1");
4571-
} else if (snapshotInfo.isRemoteStoreIndexShallowCopyEnabled()) {
4571+
} else if (Boolean.TRUE.equals(snapshotInfo.isRemoteStoreIndexShallowCopyEnabled())) {
45724572
if (shardContainer.blobExists(REMOTE_STORE_SHARD_SHALLOW_COPY_SNAPSHOT_FORMAT.blobName(snapshotId.getUUID()))) {
45734573
return REMOTE_STORE_SHARD_SHALLOW_COPY_SNAPSHOT_FORMAT.read(
45744574
shardContainer,

server/src/main/java/org/opensearch/search/approximate/ApproximatePointRangeQuery.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -449,7 +449,7 @@ public boolean canApproximate(SearchContext context) {
449449
if (context.from() + context.size() == 0) {
450450
this.setSize(SearchContext.DEFAULT_TRACK_TOTAL_HITS_UP_TO);
451451
} else {
452-
this.setSize(Math.max(context.from() + context.size(), context.trackTotalHitsUpTo() + 1));
452+
this.setSize(Math.max(context.from() + context.size(), context.trackTotalHitsUpTo()));
453453
}
454454
if (context.request() != null && context.request().source() != null) {
455455
FieldSortBuilder primarySortField = FieldSortBuilder.getPrimaryFieldSortOrNull(context.request().source());

server/src/main/java/org/opensearch/search/approximate/ApproximateScoreQuery.java

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
import org.apache.lucene.search.IndexSearcher;
1313
import org.apache.lucene.search.Query;
1414
import org.apache.lucene.search.QueryVisitor;
15+
import org.apache.lucene.search.ScoreMode;
1516
import org.apache.lucene.search.Weight;
1617
import org.opensearch.search.internal.SearchContext;
1718

@@ -47,7 +48,11 @@ public Query rewrite(IndexSearcher indexSearcher) throws IOException {
4748
// Default to the original query. This suggests that we were not called from ContextIndexSearcher.
4849
return originalQuery.rewrite(indexSearcher);
4950
}
50-
return resolvedQuery.rewrite(indexSearcher);
51+
Query rewritten = resolvedQuery.rewrite(indexSearcher);
52+
if (rewritten != resolvedQuery) {
53+
resolvedQuery = rewritten;
54+
}
55+
return this;
5156
}
5257

5358
public void setContext(SearchContext context) {
@@ -78,6 +83,15 @@ public boolean equals(Object o) {
7883
return true;
7984
}
8085

86+
@Override
87+
public Weight createWeight(IndexSearcher indexSearcher, ScoreMode scoreMode, float boost) throws IOException {
88+
if (resolvedQuery == null) {
89+
// Default to the original query.
90+
return originalQuery.createWeight(indexSearcher, scoreMode, boost);
91+
}
92+
return resolvedQuery.createWeight(indexSearcher, scoreMode, boost);
93+
}
94+
8195
@Override
8296
public int hashCode() {
8397
int h = classHash();

server/src/main/java/org/opensearch/search/query/TopDocsCollectorContext.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@
7474
import org.opensearch.common.util.CachedSupplier;
7575
import org.opensearch.index.search.OpenSearchToParentBlockJoinQuery;
7676
import org.opensearch.search.DocValueFormat;
77+
import org.opensearch.search.approximate.ApproximateScoreQuery;
7778
import org.opensearch.search.collapse.CollapseContext;
7879
import org.opensearch.search.internal.ScrollContext;
7980
import org.opensearch.search.internal.SearchContext;
@@ -724,6 +725,8 @@ static int shortcutTotalHitCount(IndexReader reader, Query query) throws IOExcep
724725
query = ((ConstantScoreQuery) query).getQuery();
725726
} else if (query instanceof BoostQuery) {
726727
query = ((BoostQuery) query).getQuery();
728+
} else if (query instanceof ApproximateScoreQuery) {
729+
query = ((ApproximateScoreQuery) query).getOriginalQuery();
727730
} else {
728731
break;
729732
}

server/src/test/java/org/opensearch/index/mapper/DateFieldTypeTests.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -287,13 +287,20 @@ public void testRangeQuery() throws IOException {
287287
String date2 = "2016-04-28T11:33:52";
288288
long instant1 = DateFormatters.from(DateFieldMapper.getDefaultDateTimeFormatter().parse(date1)).toInstant().toEpochMilli();
289289
long instant2 = DateFormatters.from(DateFieldMapper.getDefaultDateTimeFormatter().parse(date2)).toInstant().toEpochMilli() + 999;
290-
Query expected = new ApproximatePointRangeQuery(
290+
ApproximatePointRangeQuery approximatePointRangeQuery = new ApproximatePointRangeQuery(
291291
"field",
292292
pack(new long[] { instant1 }).bytes,
293293
pack(new long[] { instant2 }).bytes,
294294
new long[] { instant1 }.length,
295295
ApproximatePointRangeQuery.LONG_FORMAT
296296
);
297+
Query expected = new ApproximateScoreQuery(
298+
new IndexOrDocValuesQuery(
299+
LongPoint.newRangeQuery("field", instant1, instant2),
300+
SortedNumericDocValuesField.newSlowRangeQuery("field", instant1, instant2)
301+
),
302+
approximatePointRangeQuery
303+
);
297304
Query rangeQuery = ft.rangeQuery(date1, date2, true, true, null, null, null, context);
298305
assertTrue(rangeQuery instanceof ApproximateScoreQuery);
299306
((ApproximateScoreQuery) rangeQuery).setContext(new TestSearchContext(context));

0 commit comments

Comments
 (0)