Skip to content

Commit 8842514

Browse files
committed
Add changelog and REST test
Signed-off-by: Michael Froh <[email protected]>
1 parent b4aaa2f commit 8842514

File tree

4 files changed

+91
-2
lines changed

4 files changed

+91
-2
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
4646
### Changed
4747
- Indexed IP field supports `terms_query` with more than 1025 IP masks [#16391](https://github.com/opensearch-project/OpenSearch/pull/16391)
4848
- Make entries for dependencies from server/build.gradle to gradle version catalog ([#16707](https://github.com/opensearch-project/OpenSearch/pull/16707))
49+
- Sliced search only fans out to shards matched by the selected slice, reducing open search contexts ([#16771](https://github.com/opensearch-project/OpenSearch/pull/16771))
4950

5051
### Deprecated
5152
- Performing update operation with default pipeline or final pipeline is deprecated ([#16712](https://github.com/opensearch-project/OpenSearch/pull/16712))

rest-api-spec/src/main/resources/rest-api-spec/api/search_shards.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,9 @@
6262
"default":"open",
6363
"description":"Whether to expand wildcard expression to concrete indices that are open, closed or both."
6464
}
65+
},
66+
"body":{
67+
"description":"The search source (in order to specify slice parameters)"
6568
}
6669
}
6770
}
Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
---
2+
"Search shards with slice specified in body":
3+
- do:
4+
indices.create:
5+
index: test_index
6+
body:
7+
settings:
8+
index:
9+
number_of_shards: 7
10+
number_of_replicas: 0
11+
12+
- do:
13+
search_shards:
14+
index: test_index
15+
body:
16+
slice:
17+
id: 0
18+
max: 3
19+
- length: { shards: 3 }
20+
- match: { shards.0.0.index: "test_index" }
21+
- match: { shards.0.0.shard: 0 }
22+
- match: { shards.1.0.shard: 3 }
23+
- match: { shards.2.0.shard: 6 }
24+
25+
- do:
26+
search_shards:
27+
index: test_index
28+
body:
29+
slice:
30+
id: 1
31+
max: 3
32+
- length: { shards: 2 }
33+
- match: { shards.0.0.index: "test_index" }
34+
- match: { shards.0.0.shard: 1 }
35+
- match: { shards.1.0.shard: 4 }
36+
37+
- do:
38+
search_shards:
39+
index: test_index
40+
body:
41+
slice:
42+
id: 2
43+
max: 3
44+
- length: { shards: 2 }
45+
- match: { shards.0.0.index: "test_index" }
46+
- match: { shards.0.0.shard: 2 }
47+
- match: { shards.1.0.shard: 5 }
48+
49+
50+
- do:
51+
search_shards:
52+
index: test_index
53+
preference: "_shards:0,2,4,6"
54+
body:
55+
slice:
56+
id: 0
57+
max: 3
58+
- length: { shards: 2 }
59+
- match: { shards.0.0.index: "test_index" }
60+
- match: { shards.0.0.shard: 0 }
61+
- match: { shards.1.0.shard: 6 }
62+
63+
- do:
64+
search_shards:
65+
index: test_index
66+
preference: "_shards:0,2,4,6"
67+
body:
68+
slice:
69+
id: 1
70+
max: 3
71+
- length: { shards: 1 }
72+
- match: { shards.0.0.index: "test_index" }
73+
- match: { shards.0.0.shard: 2 }
74+
75+
- do:
76+
search_shards:
77+
index: test_index
78+
preference: "_shards:0,2,4,6"
79+
body:
80+
slice:
81+
id: 2
82+
max: 3
83+
- length: { shards: 1 }
84+
- match: { shards.0.0.index: "test_index" }
85+
- match: { shards.0.0.shard: 4 }

server/src/main/java/org/opensearch/rest/action/admin/cluster/RestClusterSearchShardsAction.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,9 +82,9 @@ public RestChannelConsumer prepareRequest(final RestRequest request, final NodeC
8282
clusterSearchShardsRequest.routing(request.param("routing"));
8383
clusterSearchShardsRequest.preference(request.param("preference"));
8484
clusterSearchShardsRequest.indicesOptions(IndicesOptions.fromRequest(request, clusterSearchShardsRequest.indicesOptions()));
85-
if (request.hasContent()) {
85+
if (request.hasContentOrSourceParam()) {
8686
SearchSourceBuilder sourceBuilder = new SearchSourceBuilder();
87-
request.withContentOrSourceParamParserOrNull(sourceBuilder::parseXContent);
87+
sourceBuilder.parseXContent(request.contentOrSourceParamParser());
8888
if (sourceBuilder.slice() != null) {
8989
clusterSearchShardsRequest.slice(sourceBuilder.slice());
9090
}

0 commit comments

Comments
 (0)