From 878143e37ff0ad5e228d3e0e43c581b868ad4496 Mon Sep 17 00:00:00 2001 From: Mantas Simkus <mantas.simkus@ongr.io> Date: Thu, 6 Aug 2015 12:04:09 +0300 Subject: [PATCH] edited FiltersAggregation docs --- docs/Aggregation/Filters.md | 35 ++++++++++++++++++++++++++++++----- 1 file changed, 30 insertions(+), 5 deletions(-) diff --git a/docs/Aggregation/Filters.md b/docs/Aggregation/Filters.md index 8ec4451..b36fecc 100644 --- a/docs/Aggregation/Filters.md +++ b/docs/Aggregation/Filters.md @@ -14,15 +14,15 @@ in exception. ```JSON { "aggregations" : { - "agg_messages" : { + "grades_stats" : { "filters" : { "filters" : { - "errors" : { "term" : { "body" : "error" }}, - "warnings" : { "term" : { "body" : "warning" }} + "error" : { "term" : { "body" : "error" }}, + "warning" : { "term" : { "body" : "warning" }} } }, "aggregations" : { - "agg_monthly" : { + "monthly" : { "histogram" : { "field" : "timestamp", "interval" : "1M" @@ -60,6 +60,31 @@ $queryArray = $search->toArray(); ## Anonymous example +```JSON +{ + "aggregations" : { + "grades_stats" : { + "filters" : { + "filters" : [ + { "term" : { "body" : "error" }}, + { "term" : { "body" : "warning" }} + ] + } + }, + "aggregations" : { + "monthly" : { + "histogram" : { + "field" : "timestamp", + "interval" : "1M" + } + } + } + } + } +} +``` +And now the query via DSL: + ```php $errorTermFilter = new TermFilter('body', 'error'); $warningTermFilter = new TermFilter('body', 'warning'); @@ -83,4 +108,4 @@ $search->addAggregation($filterAggregation); $queryArray = $search->toArray(); ``` -[1]: https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-bucket-filters-aggregation.html \ No newline at end of file +[1]: https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-bucket-filters-aggregation.html -- GitLab