Deprecate the suggest metrics (#29627)
The suggest stats were folded into the search stats as part of the indices stats API in 5.0.0. However, the suggest metric remained as a synonym for the search metric for BWC reasons. This commit deprecates usage of the suggest metric on the indices stats API. Similarly, due to the changes to fold the suggest stats into the search stats, requesting the suggest index metric on the indices metric on the nodes stats API has produced an empty object as the response since 5.0.0. This commit deprecates this index metric on the indices metric on the nodes stats API.
This commit is contained in:
parent
dfc7ca7214
commit
0045111ce2
|
@ -346,7 +346,6 @@ Supported metrics are:
|
||||||
* `search`
|
* `search`
|
||||||
* `segments`
|
* `segments`
|
||||||
* `store`
|
* `store`
|
||||||
* `suggest`
|
|
||||||
* `translog`
|
* `translog`
|
||||||
* `warmer`
|
* `warmer`
|
||||||
|
|
||||||
|
|
|
@ -146,6 +146,10 @@ public class RestNodesStatsAction extends BaseRestHandler {
|
||||||
for (final String indexMetric : indexMetrics) {
|
for (final String indexMetric : indexMetrics) {
|
||||||
final Consumer<CommonStatsFlags> handler = FLAGS.get(indexMetric);
|
final Consumer<CommonStatsFlags> handler = FLAGS.get(indexMetric);
|
||||||
if (handler != null) {
|
if (handler != null) {
|
||||||
|
if ("suggest".equals(indexMetric)) {
|
||||||
|
deprecationLogger.deprecated(
|
||||||
|
"the suggest index metric is deprecated on the nodes stats API [" + request.uri() + "]");
|
||||||
|
}
|
||||||
handler.accept(flags);
|
handler.accept(flags);
|
||||||
} else {
|
} else {
|
||||||
invalidIndexMetrics.add(indexMetric);
|
invalidIndexMetrics.add(indexMetric);
|
||||||
|
|
|
@ -102,6 +102,9 @@ public class RestIndicesStatsAction extends BaseRestHandler {
|
||||||
for (final String metric : metrics) {
|
for (final String metric : metrics) {
|
||||||
final Consumer<IndicesStatsRequest> consumer = METRICS.get(metric);
|
final Consumer<IndicesStatsRequest> consumer = METRICS.get(metric);
|
||||||
if (consumer != null) {
|
if (consumer != null) {
|
||||||
|
if ("suggest".equals(metric)) {
|
||||||
|
deprecationLogger.deprecated("the suggest metric is deprecated on the indices stats API [" + request.uri() + "]");
|
||||||
|
}
|
||||||
consumer.accept(indicesStatsRequest);
|
consumer.accept(indicesStatsRequest);
|
||||||
} else {
|
} else {
|
||||||
invalidMetrics.add(metric);
|
invalidMetrics.add(metric);
|
||||||
|
|
|
@ -20,6 +20,7 @@
|
||||||
package org.elasticsearch.rest.action.admin.cluster;
|
package org.elasticsearch.rest.action.admin.cluster;
|
||||||
|
|
||||||
import org.elasticsearch.client.node.NodeClient;
|
import org.elasticsearch.client.node.NodeClient;
|
||||||
|
import org.elasticsearch.common.collect.Tuple;
|
||||||
import org.elasticsearch.common.settings.Settings;
|
import org.elasticsearch.common.settings.Settings;
|
||||||
import org.elasticsearch.rest.RestController;
|
import org.elasticsearch.rest.RestController;
|
||||||
import org.elasticsearch.rest.RestRequest;
|
import org.elasticsearch.rest.RestRequest;
|
||||||
|
@ -31,7 +32,10 @@ import java.io.IOException;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
import static org.hamcrest.CoreMatchers.containsString;
|
import static org.hamcrest.CoreMatchers.containsString;
|
||||||
import static org.hamcrest.object.HasToString.hasToString;
|
import static org.hamcrest.object.HasToString.hasToString;
|
||||||
|
@ -144,4 +148,14 @@ public class RestNodesStatsActionTests extends ESTestCase {
|
||||||
containsString("request [/_nodes/stats] contains index metrics [" + indexMetric + "] but all stats requested")));
|
containsString("request [/_nodes/stats] contains index metrics [" + indexMetric + "] but all stats requested")));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void testSuggestIsDeprecated() throws IOException {
|
||||||
|
final Map<String, String> params =
|
||||||
|
Stream.of(Tuple.tuple("metric", "indices"), Tuple.tuple("index_metric", "suggest"))
|
||||||
|
.collect(Collectors.toMap(Tuple::v1, Tuple::v2));
|
||||||
|
final RestRequest request =
|
||||||
|
new FakeRestRequest.Builder(xContentRegistry()).withPath("/_nodes/stats").withParams(params).build();
|
||||||
|
action.prepareRequest(request, mock(NodeClient.class));
|
||||||
|
assertWarnings("the suggest index metric is deprecated on the nodes stats API [/_nodes/stats]" );
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,6 +30,7 @@ import org.elasticsearch.usage.UsageService;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
import static org.hamcrest.CoreMatchers.containsString;
|
import static org.hamcrest.CoreMatchers.containsString;
|
||||||
import static org.hamcrest.object.HasToString.hasToString;
|
import static org.hamcrest.object.HasToString.hasToString;
|
||||||
|
@ -83,4 +84,11 @@ public class RestIndicesStatsActionTests extends ESTestCase {
|
||||||
assertThat(e, hasToString(containsString("request [/_stats] contains _all and individual metrics [_all," + metric + "]")));
|
assertThat(e, hasToString(containsString("request [/_stats] contains _all and individual metrics [_all," + metric + "]")));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void testSuggestIsDeprecated() throws IOException {
|
||||||
|
final Map<String, String> params = Collections.singletonMap("metric", "suggest");
|
||||||
|
final RestRequest request = new FakeRestRequest.Builder(xContentRegistry()).withPath("/_stats").withParams(params).build();
|
||||||
|
action.prepareRequest(request, mock(NodeClient.class));
|
||||||
|
assertWarnings("the suggest metric is deprecated on the indices stats API [/_stats]");
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue