Skip to content

Commit b7f3128

Browse files
Atri SharmaAtri Sharma
authored andcommitted
More cleanup
Signed-off-by: Atri Sharma <atrisharma@Atris-Mac-Studio.local>
1 parent 6fc677b commit b7f3128

File tree

6 files changed

+3
-285
lines changed

6 files changed

+3
-285
lines changed

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

Lines changed: 0 additions & 109 deletions
This file was deleted.

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

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -24,17 +24,7 @@ public enum StreamingSearchMode {
2424
/**
2525
* No scoring and no sorting.
2626
*/
27-
NO_SCORING("no_scoring"),
28-
29-
/**
30-
* Retained for backward compatibility.
31-
*/
32-
SCORED_SORTED("scored_sorted"),
33-
34-
/**
35-
* Retained for backward compatibility.
36-
*/
37-
SCORED_UNSORTED("scored_unsorted");
27+
NO_SCORING("no_scoring");
3828

3929
private final String value;
4030

@@ -58,10 +48,6 @@ public static StreamingSearchMode fromString(String mode) {
5848
return NO_SCORING; // Default
5949
}
6050

61-
if ("SCORED_UNSORTED".equalsIgnoreCase(mode) || "SCORED_SORTED".equalsIgnoreCase(mode) || "NO_SCORING".equalsIgnoreCase(mode)) {
62-
return NO_SCORING;
63-
}
64-
6551
for (StreamingSearchMode m : StreamingSearchMode.values()) {
6652
if (m.name().equalsIgnoreCase(mode) || m.value.equalsIgnoreCase(mode)) {
6753
return m;

server/src/main/java/org/opensearch/search/streaming/StreamingSearchSettings.java

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -69,24 +69,6 @@ public final class StreamingSearchSettings {
6969
Setting.Property.Dynamic
7070
);
7171

72-
public static final Setting<Integer> STREAMING_SCORED_UNSORTED_BATCH_MULTIPLIER = Setting.intSetting(
73-
"search.streaming.scored_unsorted.batch_multiplier",
74-
2,
75-
1,
76-
100,
77-
Setting.Property.NodeScope,
78-
Setting.Property.Dynamic
79-
);
80-
81-
public static final Setting<Integer> STREAMING_SCORED_SORTED_BATCH_MULTIPLIER = Setting.intSetting(
82-
"search.streaming.scored_sorted.batch_multiplier",
83-
10,
84-
1,
85-
100,
86-
Setting.Property.NodeScope,
87-
Setting.Property.Dynamic
88-
);
89-
9072
public static final Setting<TimeValue> STREAMING_EMISSION_INTERVAL = Setting.timeSetting(
9173
"search.streaming.emission_interval",
9274
TimeValue.timeValueMillis(50),
@@ -227,9 +209,6 @@ public static List<Setting<?>> getAllSettings() {
227209
STREAMING_BLOCK_SIZE,
228210
STREAMING_BATCH_SIZE,
229211
STREAMING_NO_SCORING_BATCH_MULTIPLIER,
230-
STREAMING_SCORED_UNSORTED_BATCH_MULTIPLIER,
231-
232-
STREAMING_SCORED_SORTED_BATCH_MULTIPLIER,
233212
STREAMING_EMISSION_INTERVAL,
234213

235214
STREAMING_MIN_DOCS_FOR_STREAMING,

server/src/test/java/org/opensearch/action/search/StreamSearchIntegrationTests.java

Lines changed: 1 addition & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,11 @@
2828
import org.opensearch.index.query.QueryBuilders;
2929
import org.opensearch.plugins.NetworkPlugin;
3030
import org.opensearch.plugins.Plugin;
31-
import org.opensearch.search.SearchHit;
3231
import org.opensearch.search.aggregations.AggregationBuilders;
3332
import org.opensearch.search.aggregations.bucket.terms.StringTerms;
3433
import org.opensearch.search.aggregations.bucket.terms.TermsAggregationBuilder;
3534
import org.opensearch.search.aggregations.metrics.Max;
3635
import org.opensearch.search.aggregations.metrics.Min;
37-
import org.opensearch.search.sort.SortOrder;
3836
import org.opensearch.telemetry.tracing.Tracer;
3937
import org.opensearch.test.OpenSearchIntegTestCase;
4038
import org.opensearch.test.OpenSearchIntegTestCase.ClusterScope;
@@ -55,7 +53,7 @@
5553
* Integration tests for streaming search functionality.
5654
*
5755
* This test suite validates streaming search semantics using classic transport:
58-
* - Streaming search modes (NO_SCORING, SCORED_SORTED, SCORED_UNSORTED)
56+
* - Streaming search modes (NO_SCORING)
5957
* - StreamSearchQueryThenFetchAsyncAction with classic transport
6058
*/
6159
@ClusterScope(scope = Scope.TEST, numDataNodes = 2)
@@ -313,51 +311,6 @@ public void testStreamingAggregationTermsOnly() {
313311
}
314312
}
315313

316-
public void testStreamingSearchWithScoringModes() {
317-
// Test NO_SCORING mode - fastest TTFB
318-
SearchRequest noScoringRequest = new SearchRequest(TEST_INDEX);
319-
noScoringRequest.source().query(QueryBuilders.matchAllQuery()).size(10);
320-
noScoringRequest.searchType(SearchType.QUERY_THEN_FETCH);
321-
// Test basic search functionality without streaming
322-
// Test basic search functionality without streaming
323-
// noScoringRequest.setStreamingSearchMode(StreamingSearchMode.NO_SCORING.toString());
324-
// noScoringRequest.setStreamingScoring(true);
325-
326-
SearchResponse noScoringResponse = client().execute(SearchAction.INSTANCE, noScoringRequest).actionGet();
327-
assertNotNull("Response should not be null for NO_SCORING mode", noScoringResponse);
328-
assertNotNull("Response hits should not be null", noScoringResponse.getHits());
329-
assertTrue("Should have search hits", noScoringResponse.getHits().getTotalHits().value() > 0);
330-
331-
// Test SCORED_SORTED mode - full scoring with sorting
332-
SearchRequest scoredSortedRequest = new SearchRequest(TEST_INDEX);
333-
scoredSortedRequest.source().query(QueryBuilders.matchQuery("field1", "value1")).size(10).sort("_score", SortOrder.DESC);
334-
scoredSortedRequest.searchType(SearchType.QUERY_THEN_FETCH);
335-
// Test basic search functionality without streaming
336-
// Test basic search functionality without streaming
337-
// scoredSortedRequest.setStreamingSearchMode(StreamingSearchMode.SCORED_SORTED.toString());
338-
// scoredSortedRequest.setStreamingScoring(true);
339-
340-
SearchResponse scoredSortedResponse = client().execute(SearchAction.INSTANCE, scoredSortedRequest).actionGet();
341-
assertNotNull("Response should not be null for SCORED_SORTED mode", scoredSortedResponse);
342-
assertNotNull("Response hits should not be null", scoredSortedResponse.getHits());
343-
344-
// Verify hits are sorted by score
345-
SearchHit[] hits = scoredSortedResponse.getHits().getHits();
346-
for (int i = 1; i < hits.length; i++) {
347-
assertTrue("Hits should be sorted by score", hits[i - 1].getScore() >= hits[i].getScore());
348-
}
349-
350-
// Test SCORED_UNSORTED mode - scoring without sorting
351-
SearchRequest scoredUnsortedRequest = new SearchRequest(TEST_INDEX);
352-
scoredUnsortedRequest.source().query(QueryBuilders.matchQuery("field1", "value1")).size(5);
353-
scoredUnsortedRequest.searchType(SearchType.QUERY_THEN_FETCH);
354-
355-
SearchResponse scoredUnsortedResponse = client().execute(SearchAction.INSTANCE, scoredUnsortedRequest).actionGet();
356-
assertNotNull("Response should not be null for SCORED_UNSORTED mode", scoredUnsortedResponse);
357-
assertNotNull("Response hits should not be null", scoredUnsortedResponse.getHits());
358-
assertTrue("Should have search hits", scoredUnsortedResponse.getHits().getTotalHits().value() > 0);
359-
}
360-
361314
private void createTestIndex() {
362315
Settings indexSettings = Settings.builder()
363316
.put("index.number_of_shards", NUM_SHARDS)

server/src/test/java/org/opensearch/search/DefaultSearchContextStreamingTests.java

Lines changed: 0 additions & 91 deletions
Original file line numberDiff line numberDiff line change
@@ -147,97 +147,6 @@ protected Engine.Searcher acquireSearcherInternal(String source) {
147147
}
148148
}
149149

150-
public void testStreamingFlagsScoredUnsortedMode() throws Exception {
151-
ThreadPool threadPool = new TestThreadPool(this.getClass().getName());
152-
153-
try (Directory dir = newDirectory(); RandomIndexWriter w = new RandomIndexWriter(random(), dir)) {
154-
ShardSearchRequest shardSearchRequest = mock(ShardSearchRequest.class);
155-
when(shardSearchRequest.searchType()).thenReturn(SearchType.DEFAULT);
156-
when(shardSearchRequest.getStreamingSearchMode()).thenReturn(StreamingSearchMode.SCORED_UNSORTED.toString());
157-
158-
ShardId shardId = new ShardId("test-index", UUID.randomUUID().toString(), 0);
159-
when(shardSearchRequest.shardId()).thenReturn(shardId);
160-
161-
IndexShard indexShard = mock(IndexShard.class);
162-
QueryCachingPolicy queryCachingPolicy = mock(QueryCachingPolicy.class);
163-
when(indexShard.getQueryCachingPolicy()).thenReturn(queryCachingPolicy);
164-
when(indexShard.getThreadPool()).thenReturn(threadPool);
165-
166-
org.opensearch.cluster.metadata.IndexMetadata indexMetadata = org.opensearch.cluster.metadata.IndexMetadata.builder(
167-
"test-index"
168-
)
169-
.settings(
170-
Settings.builder()
171-
.put(org.opensearch.cluster.metadata.IndexMetadata.SETTING_VERSION_CREATED, org.opensearch.Version.CURRENT)
172-
.put(org.opensearch.cluster.metadata.IndexMetadata.SETTING_NUMBER_OF_SHARDS, 1)
173-
.put(org.opensearch.cluster.metadata.IndexMetadata.SETTING_NUMBER_OF_REPLICAS, 0)
174-
)
175-
.build();
176-
org.opensearch.index.IndexSettings indexSettings = new org.opensearch.index.IndexSettings(indexMetadata, Settings.EMPTY);
177-
when(indexShard.indexSettings()).thenReturn(indexSettings);
178-
179-
IndexService indexService = mock(IndexService.class);
180-
BigArrays bigArrays = new MockBigArrays(new MockPageCacheRecycler(Settings.EMPTY), new NoneCircuitBreakerService());
181-
182-
final Supplier<Engine.SearcherSupplier> searcherSupplier = () -> new Engine.SearcherSupplier(Function.identity()) {
183-
@Override
184-
protected void doClose() {}
185-
186-
@Override
187-
protected Engine.Searcher acquireSearcherInternal(String source) {
188-
try {
189-
IndexReader reader = w.getReader();
190-
return new Engine.Searcher(
191-
"test",
192-
reader,
193-
IndexSearcher.getDefaultSimilarity(),
194-
IndexSearcher.getDefaultQueryCache(),
195-
IndexSearcher.getDefaultQueryCachingPolicy(),
196-
reader
197-
);
198-
} catch (IOException exc) {
199-
throw new AssertionError(exc);
200-
}
201-
}
202-
};
203-
204-
SearchShardTarget target = new SearchShardTarget("node1", shardId, null, OriginalIndices.NONE);
205-
ReaderContext readerContext = new ReaderContext(
206-
new ShardSearchContextId(UUIDs.randomBase64UUID(), randomNonNegativeLong()),
207-
indexService,
208-
indexShard,
209-
searcherSupplier.get(),
210-
randomNonNegativeLong(),
211-
false
212-
);
213-
214-
DefaultSearchContext context = new DefaultSearchContext(
215-
readerContext,
216-
shardSearchRequest,
217-
target,
218-
null,
219-
bigArrays,
220-
null,
221-
null,
222-
null,
223-
false,
224-
Version.CURRENT,
225-
false,
226-
null,
227-
null,
228-
Collections.emptyList()
229-
);
230-
231-
assertTrue(context.isStreamingSearch());
232-
assertEquals(StreamingSearchMode.NO_SCORING, context.getStreamingMode());
233-
assertEquals(FlushMode.PER_SEGMENT, context.getFlushMode());
234-
235-
context.close();
236-
} finally {
237-
threadPool.shutdown();
238-
}
239-
}
240-
241150
public void testNonStreamingDoesNotSetStreamingFlags() throws Exception {
242151
ThreadPool threadPool = new TestThreadPool(this.getClass().getName());
243152

server/src/test/java/org/opensearch/search/aggregations/bucket/terms/StreamStringTermsAggregatorTests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -419,7 +419,7 @@ private void doAggOverManySegments(boolean profile) throws IOException {
419419
);
420420
when(searchContext.isStreamSearch()).thenReturn(true);
421421
when(searchContext.isStreamingModeRequested()).thenReturn(true);
422-
when(searchContext.getStreamingMode()).thenReturn(org.opensearch.search.query.StreamingSearchMode.SCORED_UNSORTED);
422+
when(searchContext.getStreamingMode()).thenReturn(org.opensearch.search.query.StreamingSearchMode.NO_SCORING);
423423
when(searchContext.getFlushMode()).thenReturn(FlushMode.PER_SEGMENT);
424424
SearchShardTarget searchShardTarget = new SearchShardTarget(
425425
"node_1",

0 commit comments

Comments
 (0)