Skip to content

Commit eadaabd

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

File tree

4 files changed

+94
-2
lines changed

4 files changed

+94
-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: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
---
2+
"Search shards with slice specified in body":
3+
- skip:
4+
version: " - 2.99.99"
5+
reason: "Added slice body to search_shards in 2.19"
6+
- do:
7+
indices.create:
8+
index: test_index
9+
body:
10+
settings:
11+
index:
12+
number_of_shards: 7
13+
number_of_replicas: 0
14+
15+
- do:
16+
search_shards:
17+
index: test_index
18+
body:
19+
slice:
20+
id: 0
21+
max: 3
22+
- length: { shards: 3 }
23+
- match: { shards.0.0.index: "test_index" }
24+
- match: { shards.0.0.shard: 0 }
25+
- match: { shards.1.0.shard: 3 }
26+
- match: { shards.2.0.shard: 6 }
27+
28+
- do:
29+
search_shards:
30+
index: test_index
31+
body:
32+
slice:
33+
id: 1
34+
max: 3
35+
- length: { shards: 2 }
36+
- match: { shards.0.0.index: "test_index" }
37+
- match: { shards.0.0.shard: 1 }
38+
- match: { shards.1.0.shard: 4 }
39+
40+
- do:
41+
search_shards:
42+
index: test_index
43+
body:
44+
slice:
45+
id: 2
46+
max: 3
47+
- length: { shards: 2 }
48+
- match: { shards.0.0.index: "test_index" }
49+
- match: { shards.0.0.shard: 2 }
50+
- match: { shards.1.0.shard: 5 }
51+
52+
53+
- do:
54+
search_shards:
55+
index: test_index
56+
preference: "_shards:0,2,4,6"
57+
body:
58+
slice:
59+
id: 0
60+
max: 3
61+
- length: { shards: 2 }
62+
- match: { shards.0.0.index: "test_index" }
63+
- match: { shards.0.0.shard: 0 }
64+
- match: { shards.1.0.shard: 6 }
65+
66+
- do:
67+
search_shards:
68+
index: test_index
69+
preference: "_shards:0,2,4,6"
70+
body:
71+
slice:
72+
id: 1
73+
max: 3
74+
- length: { shards: 1 }
75+
- match: { shards.0.0.index: "test_index" }
76+
- match: { shards.0.0.shard: 2 }
77+
78+
- do:
79+
search_shards:
80+
index: test_index
81+
preference: "_shards:0,2,4,6"
82+
body:
83+
slice:
84+
id: 2
85+
max: 3
86+
- length: { shards: 1 }
87+
- match: { shards.0.0.index: "test_index" }
88+
- 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)