Skip to content

Commit 2c3e71f

Browse files
authored
Remove the suggest metric from stats APIs (#29635)
This metric previously existed for backwards compatibility reasons although the suggest stats were folded into search stats. This metric was deprecated in 6.3.0 and this commit removes them for 7.0.0.
1 parent 25e45a7 commit 2c3e71f

File tree

11 files changed

+12
-58
lines changed

11 files changed

+12
-58
lines changed

docs/CHANGELOG.asciidoc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
<<write-thread-pool-fallback, Removed `thread_pool.bulk.*` settings and
1313
`es.thread_pool.write.use_bulk_as_display_name` system property>> ({pull}29609[#29609])
1414

15+
<<remove-suggest-metric, Removed `suggest` metric on stats APIs>> ({pull}29635[#29635])
16+
1517
=== Breaking Java Changes
1618

1719
=== Deprecations

docs/reference/migration/migrate_7_0/api.asciidoc

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,14 @@ The following parameters starting with underscore have been removed:
2222
Instead of these removed parameters, use their non camel case equivalents without
2323
starting underscore, e.g. use `version_type` instead of `_version_type` or `versionType`.
2424

25-
2625
==== The parameter `fields` deprecated in 6.x has been removed from Bulk request
2726
and Update request. The Update API returns `400 - Bad request` if request contains
2827
unknown parameters (instead of ignored in the previous version).
28+
29+
[[remove-suggest-metric]]
30+
==== Remove support for `suggest` metric/index metric in indices stats and nodes stats APIs
31+
32+
Previously, `suggest` stats were folded into `search` stats. Support for the
33+
`suggest` metric on the indices stats and nodes stats APIs remained for
34+
backwards compatibility. Backwards support for the `suggest` metric was
35+
deprecated in 6.3.0 and now removed in 7.0.0.

server/src/main/java/org/elasticsearch/action/admin/indices/stats/CommonStats.java

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -152,9 +152,6 @@ public CommonStats(CommonStatsFlags flags) {
152152
case Translog:
153153
translog = new TranslogStats();
154154
break;
155-
case Suggest:
156-
// skip
157-
break;
158155
case RequestCache:
159156
requestCache = new RequestCacheStats();
160157
break;
@@ -213,9 +210,6 @@ public CommonStats(IndicesQueryCache indicesQueryCache, IndexShard indexShard, C
213210
case Translog:
214211
translog = indexShard.translogStats();
215212
break;
216-
case Suggest:
217-
// skip
218-
break;
219213
case RequestCache:
220214
requestCache = indexShard.requestCache().stats();
221215
break;

server/src/main/java/org/elasticsearch/action/admin/indices/stats/CommonStatsFlags.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ public enum Flag {
221221
Completion("completion", 11),
222222
Segments("segments", 12),
223223
Translog("translog", 13),
224-
Suggest("suggest", 14), // unused
224+
// 14 was previously used for Suggest
225225
RequestCache("request_cache", 15),
226226
Recovery("recovery", 16);
227227

server/src/main/java/org/elasticsearch/action/admin/indices/stats/IndicesStatsRequest.java

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -229,15 +229,6 @@ public boolean translog() {
229229
return flags.isSet(Flag.Translog);
230230
}
231231

232-
public IndicesStatsRequest suggest(boolean suggest) {
233-
flags.set(Flag.Suggest, suggest);
234-
return this;
235-
}
236-
237-
public boolean suggest() {
238-
return flags.isSet(Flag.Suggest);
239-
}
240-
241232
public IndicesStatsRequest requestCache(boolean requestCache) {
242233
flags.set(Flag.RequestCache, requestCache);
243234
return this;

server/src/main/java/org/elasticsearch/action/admin/indices/stats/TransportIndicesStatsAction.java

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -148,9 +148,6 @@ protected ShardStats shardOperation(IndicesStatsRequest request, ShardRouting sh
148148
if (request.translog()) {
149149
flags.set(CommonStatsFlags.Flag.Translog);
150150
}
151-
if (request.suggest()) {
152-
flags.set(CommonStatsFlags.Flag.Suggest);
153-
}
154151
if (request.requestCache()) {
155152
flags.set(CommonStatsFlags.Flag.RequestCache);
156153
}

server/src/main/java/org/elasticsearch/rest/action/admin/cluster/RestNodesStatsAction.java

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -146,10 +146,6 @@ public RestChannelConsumer prepareRequest(final RestRequest request, final NodeC
146146
for (final String indexMetric : indexMetrics) {
147147
final Consumer<CommonStatsFlags> handler = FLAGS.get(indexMetric);
148148
if (handler != null) {
149-
if ("suggest".equals(indexMetric)) {
150-
deprecationLogger.deprecated(
151-
"the suggest index metric is deprecated on the nodes stats API [" + request.uri() + "]");
152-
}
153149
handler.accept(flags);
154150
} else {
155151
invalidIndexMetrics.add(indexMetric);

server/src/main/java/org/elasticsearch/rest/action/admin/indices/RestIndicesStatsAction.java

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,6 @@ public String getName() {
6262
metrics.put("store", r -> r.store(true));
6363
metrics.put("indexing", r -> r.indexing(true));
6464
metrics.put("search", r -> r.search(true));
65-
metrics.put("suggest", r -> r.search(true));
6665
metrics.put("get", r -> r.get(true));
6766
metrics.put("merge", r -> r.merge(true));
6867
metrics.put("refresh", r -> r.refresh(true));
@@ -102,9 +101,6 @@ public RestChannelConsumer prepareRequest(final RestRequest request, final NodeC
102101
for (final String metric : metrics) {
103102
final Consumer<IndicesStatsRequest> consumer = METRICS.get(metric);
104103
if (consumer != null) {
105-
if ("suggest".equals(metric)) {
106-
deprecationLogger.deprecated("the suggest metric is deprecated on the indices stats API [" + request.uri() + "]");
107-
}
108104
consumer.accept(indicesStatsRequest);
109105
} else {
110106
invalidMetrics.add(metric);

server/src/test/java/org/elasticsearch/indices/stats/IndexStatsIT.java

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -589,10 +589,6 @@ public void testAllFlags() throws Exception {
589589

590590
IndicesStatsResponse stats = builder.execute().actionGet();
591591
for (Flag flag : values) {
592-
if (flag == Flag.Suggest) {
593-
// suggest flag is unused
594-
continue;
595-
}
596592
assertThat(isSet(flag, stats.getPrimaries()), equalTo(false));
597593
assertThat(isSet(flag, stats.getTotal()), equalTo(false));
598594
}
@@ -628,10 +624,6 @@ public void testAllFlags() throws Exception {
628624
}
629625

630626
for (Flag flag : EnumSet.complementOf(flags)) { // check the complement
631-
if (flag == Flag.Suggest) {
632-
// suggest flag is unused
633-
continue;
634-
}
635627
assertThat(isSet(flag, stats.getPrimaries()), equalTo(false));
636628
assertThat(isSet(flag, stats.getTotal()), equalTo(false));
637629
}
@@ -684,7 +676,7 @@ public void testEncodeDecodeCommonStats() throws IOException {
684676
public void testFlagOrdinalOrder() {
685677
Flag[] flags = new Flag[]{Flag.Store, Flag.Indexing, Flag.Get, Flag.Search, Flag.Merge, Flag.Flush, Flag.Refresh,
686678
Flag.QueryCache, Flag.FieldData, Flag.Docs, Flag.Warmer, Flag.Completion, Flag.Segments,
687-
Flag.Translog, Flag.Suggest, Flag.RequestCache, Flag.Recovery};
679+
Flag.Translog, Flag.RequestCache, Flag.Recovery};
688680

689681
assertThat(flags.length, equalTo(Flag.values().length));
690682
for (int i = 0; i < flags.length; i++) {
@@ -935,8 +927,6 @@ private static void set(Flag flag, IndicesStatsRequestBuilder builder, boolean s
935927
case Translog:
936928
builder.setTranslog(set);
937929
break;
938-
case Suggest: // unused
939-
break;
940930
case RequestCache:
941931
builder.setRequestCache(set);
942932
break;
@@ -979,8 +969,6 @@ private static boolean isSet(Flag flag, CommonStats response) {
979969
return response.getSegments() != null;
980970
case Translog:
981971
return response.getTranslog() != null;
982-
case Suggest: // unused
983-
return true;
984972
case RequestCache:
985973
return response.getRequestCache() != null;
986974
case Recovery:

server/src/test/java/org/elasticsearch/rest/action/admin/cluster/RestNodesStatsActionTests.java

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -148,14 +148,4 @@ public void testIndexMetricsRequestOnAllRequest() throws IOException {
148148
containsString("request [/_nodes/stats] contains index metrics [" + indexMetric + "] but all stats requested")));
149149
}
150150

151-
public void testSuggestIsDeprecated() throws IOException {
152-
final Map<String, String> params =
153-
Stream.of(Tuple.tuple("metric", "indices"), Tuple.tuple("index_metric", "suggest"))
154-
.collect(Collectors.toMap(Tuple::v1, Tuple::v2));
155-
final RestRequest request =
156-
new FakeRestRequest.Builder(xContentRegistry()).withPath("/_nodes/stats").withParams(params).build();
157-
action.prepareRequest(request, mock(NodeClient.class));
158-
assertWarnings("the suggest index metric is deprecated on the nodes stats API [/_nodes/stats]" );
159-
}
160-
161151
}

server/src/test/java/org/elasticsearch/rest/action/admin/indices/RestIndicesStatsActionTests.java

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -84,11 +84,4 @@ public void testAllRequestWithOtherMetrics() throws IOException {
8484
assertThat(e, hasToString(containsString("request [/_stats] contains _all and individual metrics [_all," + metric + "]")));
8585
}
8686

87-
public void testSuggestIsDeprecated() throws IOException {
88-
final Map<String, String> params = Collections.singletonMap("metric", "suggest");
89-
final RestRequest request = new FakeRestRequest.Builder(xContentRegistry()).withPath("/_stats").withParams(params).build();
90-
action.prepareRequest(request, mock(NodeClient.class));
91-
assertWarnings("the suggest metric is deprecated on the indices stats API [/_stats]");
92-
}
93-
9487
}

0 commit comments

Comments
 (0)