Skip to content

Commit 8ce9cc1

Browse files
Merge branch 'main' into field_alias
2 parents 50a0604 + bf8cd25 commit 8ce9cc1

File tree

13 files changed

+58
-22
lines changed

13 files changed

+58
-22
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

1920
### Changed
2021

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

2931
### Deprecated
3032

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

4144
### Security
4245

plugins/ingestion-kafka/src/internalClusterTest/java/org/opensearch/plugin/kafka/RemoteStoreKafkaIT.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -198,8 +198,9 @@ public void testPauseAndResumeIngestion() throws Exception {
198198
assertTrue(pauseResponse.isShardsAcknowledged());
199199
waitForState(() -> {
200200
GetIngestionStateResponse ingestionState = getIngestionState(indexName);
201-
return Arrays.stream(ingestionState.getShardStates())
202-
.allMatch(state -> state.isPollerPaused() && state.pollerState().equalsIgnoreCase("paused"));
201+
return ingestionState.getFailedShards() == 0
202+
&& Arrays.stream(ingestionState.getShardStates())
203+
.allMatch(state -> state.isPollerPaused() && state.pollerState().equalsIgnoreCase("paused"));
203204
});
204205

205206
// verify ingestion state is persisted

plugins/ingestion-kafka/src/test/java/org/opensearch/plugin/kafka/KafkaUtils.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ public static void createTopic(String topicName, int numOfPartitions, String boo
5353
}
5454

5555
// validates topic is created
56-
await().atMost(10, TimeUnit.SECONDS).until(() -> checkTopicExistence(topicName, bootstrapServers));
56+
await().atMost(60, TimeUnit.SECONDS).until(() -> checkTopicExistence(topicName, bootstrapServers));
5757
}
5858

5959
public static boolean checkTopicExistence(String topicName, String bootstrapServers) {

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

plugins/transport-reactor-netty4/src/javaRestTest/java/org/opensearch/rest/ReactorNetty4StreamingStressIT.java

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
import org.opensearch.client.Response;
1414
import org.opensearch.client.StreamingRequest;
1515
import org.opensearch.client.StreamingResponse;
16+
import org.opensearch.common.settings.Settings;
1617
import org.opensearch.test.rest.OpenSearchRestTestCase;
1718
import org.junit.After;
1819

@@ -22,6 +23,7 @@
2223
import java.nio.ByteBuffer;
2324
import java.nio.charset.StandardCharsets;
2425
import java.time.Duration;
26+
import java.util.concurrent.TimeoutException;
2527
import java.util.concurrent.atomic.AtomicInteger;
2628
import java.util.stream.Stream;
2729

@@ -44,7 +46,11 @@ public void tearDown() throws Exception {
4446
super.tearDown();
4547
}
4648

47-
@AwaitsFix(bugUrl = "https://github.com/opensearch-project/OpenSearch/issues/15840")
49+
@Override
50+
protected Settings restClientSettings() {
51+
return Settings.builder().put(super.restClientSettings()).put(CLIENT_SOCKET_TIMEOUT, "5s").build();
52+
}
53+
4854
public void testCloseClientStreamingRequest() throws Exception {
4955
final VirtualTimeScheduler scheduler = VirtualTimeScheduler.create(true);
5056

@@ -67,17 +73,19 @@ public void testCloseClientStreamingRequest() throws Exception {
6773
final StreamingResponse<ByteBuffer> streamingResponse = client().streamRequest(streamingRequest);
6874
scheduler.advanceTimeBy(delay); /* emit first element */
6975

70-
StepVerifier.create(Flux.from(streamingResponse.getBody()).map(b -> new String(b.array(), StandardCharsets.UTF_8)))
71-
.expectNextMatches(s -> s.contains("\"result\":\"created\"") && s.contains("\"_id\":\"1\""))
72-
.then(() -> {
73-
try {
74-
client().close();
75-
} catch (final IOException ex) {
76-
throw new UncheckedIOException(ex);
77-
}
78-
})
76+
StepVerifier.create(
77+
Flux.from(streamingResponse.getBody()).timeout(Duration.ofSeconds(5)).map(b -> new String(b.array(), StandardCharsets.UTF_8))
78+
).expectNextMatches(s -> s.contains("\"result\":\"created\"") && s.contains("\"_id\":\"1\"")).then(() -> {
79+
try {
80+
client().close();
81+
} catch (final IOException ex) {
82+
throw new UncheckedIOException(ex);
83+
}
84+
})
7985
.then(() -> scheduler.advanceTimeBy(delay))
80-
.expectErrorMatches(t -> t instanceof InterruptedIOException || t instanceof ConnectionClosedException)
86+
.expectErrorMatches(
87+
t -> t instanceof InterruptedIOException || t instanceof ConnectionClosedException || t instanceof TimeoutException
88+
)
8189
.verify(Duration.ofSeconds(10));
8290
}
8391
}

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)