field_stats: Search field statistics

Description Usage Arguments Details Note References See Also Examples

View source: R/field_stats.R

Description

Search field statistics

Usage

1
2
field_stats(fields = NULL, index = NULL, level = "cluster",
  body = list(), raw = FALSE, asdf = FALSE, ...)

Arguments

fields

A list of fields to compute stats for. optional

index

Index name, one or more

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' (default)

body

Query, either a list or json

raw

(logical) Get raw JSON back or not

asdf

(logical) If TRUE, use fromJSON to parse JSON directly to a data.frame. If FALSE (Default), list output is given.

...

Curl args passed on to httr::POST()

Details

The field stats api allows you to get statistical properties of a field without executing a search, but looking up measurements that are natively 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.

Note

Deprecated in Elasticsearch versions equal to/greater than 5.4.0

References

https://www.elastic.co/guide/en/elasticsearch/reference/5.6/search-field-stats.html

See Also

field_caps()

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
## Not run: 
connect()

if (gsub("\\.", "", ping()$version$number) < 500) {
  field_stats(body = '{ "fields": ["speaker"] }', index = "shakespeare")
  ff <- c("scientificName", "continent", "decimalLatitude", "play_name", 
    "speech_number")
  field_stats("play_name")
  field_stats("play_name", level = "cluster")
  field_stats(ff, level = "indices")
  field_stats(ff)
  field_stats(ff, index = c("gbif", "shakespeare"))

  # can also pass a body, just as with Search()
  # field_stats(body = list(fields = "rating")) # doesn't work
  field_stats(body = '{ "fields": ["scientificName"] }', index = "gbif")

  body <- '{
    "fields" : ["scientificName", "decimalLatitude"]
  }'
  field_stats(body = body, level = "indices", index = "gbif")
}

## End(Not run)

ropensci/elastic documentation built on Oct. 13, 2018, 1:45 p.m.