Learn R Programming

elastic (version 0.7.8)

field_stats: Search field statistics

Description

Search field statistics

Usage

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

Arguments

fields

A list of fields to compute stats for. Required.

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 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.

See Also

Search_uri Search msearch

Examples

Run this code
# NOT RUN {
connect()
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")
# }

Run the code above in your browser using DataLab