Docs: Tidied up the field statistics docs

This commit is contained in:
Clinton Gormley 2015-05-24 15:08:27 +02:00
parent c08481f523
commit 4b854d10bd

View File

@ -3,11 +3,14 @@
experimental[] experimental[]
The field stats api allows one to find statistical properties of a field without executing a search, but The field stats api allows one to find statistical properties of a field
looking up measurements that are natively available in the Lucene index. This can be useful to explore a dataset which without executing a search, but looking up measurements that are natively
you don't know much about. For example, this allows creating a histogram aggregation with meaningful intervals. available in the Lucene index. This can be useful to explore a dataset which
you don't know much about. For example, this allows creating a histogram
aggregation with meaningful intervals based on the min/max range of values.
The field stats api by defaults executes on all indices, but can execute on specific indices too. The field stats api by defaults executes on all indices, but can execute on
specific indices too.
All indices: All indices:
@ -26,15 +29,11 @@ curl -XGET "http://localhost:9200/index1,index2/_field_stats?fields=rating"
Supported request options: Supported request options:
[horizontal] [horizontal]
`fields`:: `fields`:: A list of fields to compute stats for.
`level`:: Defines if field stats should be returned on a per index level or on a
A list of fields to compute stats for. cluster wide level. Valid values are `indices` and `cluster` (default).
`level`::
Defines if field stats should be returned on a per index level or on a cluster
wide level. Valid values are `indices` and `cluster`. Defaults to `cluster`.
[float]
=== Field statistics === Field statistics
The field stats api is supported on string based, number based and date based fields and can return the following statistics per field: The field stats api is supported on string based, number based and date based fields and can return the following statistics per field:
@ -57,13 +56,13 @@ is a derived statistic and is based on the `max_doc` and `doc_count`.
`sum_doc_freq`:: `sum_doc_freq`::
The sum of each term's document frequency in this field, or -1 if this The sum of each term's document frequency in this field, or -1 if this
measurement isn't available on one or more shards. Document frequency is the measurement isn't available on one or more shards.
number of documents containing a particular term. Document frequency is the number of documents containing a particular term.
`sum_total_term_freq`:: `sum_total_term_freq`::
The sum of the term frequencies of all terms in this field across all The sum of the term frequencies of all terms in this field across all
documents, or `-1` if this measurement isn't available on one or more shards. documents, or -1 if this measurement isn't available on one or more shards.
Term frequency is the total number of occurrences of a term in a particular Term frequency is the total number of occurrences of a term in a particular
document and field. document and field.
@ -75,18 +74,19 @@ The lowest value in the field represented in a displayable form.
The highest value in the field represented in a displayable form. The highest value in the field represented in a displayable form.
NOTE: For all the mentioned statistics, documents marked as deleted aren't taken into account. The documents marked NOTE: Documents marked as deleted (but not yet removed by the merge process)
as deleted are are only taken into account when the segments these documents reside on are merged away. still affect all the mentioned statistics.
[float]
=== Example .Cluster level field statistics
==================================================
[source,js] [source,js]
-------------------------------------------------- --------------------------------------------------
curl -XGET "http://localhost:9200/_field_stats?fields=rating,answer_count,creation_date,display_name" GET /_field_stats?fields=rating,answer_count,creation_date,display_name
-------------------------------------------------- --------------------------------------------------
[source,js] [source,json]
-------------------------------------------------- --------------------------------------------------
{ {
"_shards": { "_shards": {
@ -140,12 +140,14 @@ curl -XGET "http://localhost:9200/_field_stats?fields=rating,answer_count,creati
-------------------------------------------------- --------------------------------------------------
<1> The `_all` key indicates that it contains the field stats of all indices in the cluster. <1> The `_all` key indicates that it contains the field stats of all indices in the cluster.
==================================================
With level set to `indices`: .Indices level field statistics
==================================================
[source,js] [source,js]
-------------------------------------------------- --------------------------------------------------
curl -XGET "http://localhost:9200/_field_stats?fields=rating,answer_count,creation_date,display_name&level=indices" GET /_field_stats?fields=rating,answer_count,creation_date,display_name&level=indices
-------------------------------------------------- --------------------------------------------------
[source,js] [source,js]
@ -201,4 +203,6 @@ curl -XGET "http://localhost:9200/_field_stats?fields=rating,answer_count,creati
} }
-------------------------------------------------- --------------------------------------------------
<1> The `stack` key means it contains all field stats for the `stack` index. <1> The `stack` key means it contains all field stats for the `stack` index.
==================================================