diff --git a/docs/reference/indices/stats.asciidoc b/docs/reference/indices/stats.asciidoc index 0468a8cb202..26a154d5d27 100644 --- a/docs/reference/indices/stats.asciidoc +++ b/docs/reference/indices/stats.asciidoc @@ -39,11 +39,20 @@ are returned, other stats can be enabled as well: groups). `warmer`:: Warmer statistics. -`merge`:: merge stats. -`flush`:: flush stats. -`refresh`:: refresh stats. +`merge`:: Merge statistics. +`fielddata`:: Fielddata statistics. +`flush`:: Flush statistics. +`completion`:: Completion suggest statistics. +`refresh`:: Refresh statistics. `clear`:: Clears all the flags (first). +Some statistics allow per field granularity which accepts a list comma-separated list of included fields. By default all fields are included: + +[horizontal] +`fields`:: List of fields to be included in the statistics. This is used as the default list unless a more specific field list is provided (see below). +`completion_fields`:: List of fields to be included in the Completion Suggest statistics +`fielddata_fields`:: List of fields to be included in the Fielddata statistics + Here are some samples: [source,js] diff --git a/src/main/java/org/elasticsearch/rest/action/admin/indices/stats/RestIndicesStatsAction.java b/src/main/java/org/elasticsearch/rest/action/admin/indices/stats/RestIndicesStatsAction.java index d3eca0eac0b..0431c539438 100644 --- a/src/main/java/org/elasticsearch/rest/action/admin/indices/stats/RestIndicesStatsAction.java +++ b/src/main/java/org/elasticsearch/rest/action/admin/indices/stats/RestIndicesStatsAction.java @@ -35,7 +35,7 @@ import java.io.IOException; import static org.elasticsearch.rest.RestRequest.Method.GET; import static org.elasticsearch.rest.RestStatus.OK; -import static org.elasticsearch.rest.action.support.RestActions.*; +import static org.elasticsearch.rest.action.support.RestActions.buildBroadcastShardsHeader; /** */ @@ -118,6 +118,9 @@ public class RestIndicesStatsAction extends BaseRestHandler { if (request.hasParam("groups")) { indicesStatsRequest.groups(Strings.splitStringByCommaToArray(request.param("groups"))); } + /* We use "fields" as the default field list for stats that support field inclusion filters and further down + * a more specific list of fields that overrides this list.*/ + final String[] defaultIncludedFields = request.paramAsStringArray("fields", null); indicesStatsRequest.docs(request.paramAsBoolean("docs", indicesStatsRequest.docs())); indicesStatsRequest.store(request.paramAsBoolean("store", indicesStatsRequest.store())); indicesStatsRequest.indexing(request.paramAsBoolean("indexing", indicesStatsRequest.indexing())); @@ -130,8 +133,10 @@ public class RestIndicesStatsAction extends BaseRestHandler { indicesStatsRequest.filterCache(request.paramAsBoolean("filter_cache", indicesStatsRequest.filterCache())); indicesStatsRequest.idCache(request.paramAsBoolean("id_cache", indicesStatsRequest.idCache())); indicesStatsRequest.fieldData(request.paramAsBoolean("fielddata", indicesStatsRequest.fieldData())); - indicesStatsRequest.fieldDataFields(request.paramAsStringArray("fields", null)); + indicesStatsRequest.fieldDataFields(request.paramAsStringArray("fielddata_fields", defaultIncludedFields)); indicesStatsRequest.percolate(request.paramAsBoolean("percolate", indicesStatsRequest.percolate())); + indicesStatsRequest.completion(request.paramAsBoolean("completion", indicesStatsRequest.completion())); + indicesStatsRequest.completionFields(request.paramAsStringArray("completion_fields", defaultIncludedFields)); client.admin().indices().stats(indicesStatsRequest, new ActionListener() { @Override