plus-.elastic_api: Define Elasticsearch aggregation on a secific subset of...

Description Usage Arguments Value Examples

Description

Sometimes it is necessary to perform an aggregation on the results of a query (i.e. on a subset of all the available documents). This is achieved by adding an aggs object to a query object.

Usage

1
2
## S3 method for class 'elastic_api'
x + y

Arguments

x

elastic_query object.

y

elastic_aggs or elastic_sort object.

Value

elastic_aggs object that contains the query information required for the aggregation.

Examples

1
2
3
4
5
6
7
8
9
all_docs <- query('{"match_all": {}}')
avg_sepal_width_per_cat <- aggs('{"avg_sepal_width_per_cat": {
      "terms": {"field": "species"},
      "aggs": {"avg_sepal_width": {"avg": {"field": "sepal_width"}}}}
}')
all_docs + avg_sepal_width_per_cat

sort_by_sepal_width <- sort_on('[{"sepal_width": {"order": "asc"}}]')
all_docs + sort_by_sepal_width

AlexIoannides/elasticsearchr documentation built on July 31, 2019, 9:36 a.m.