Skip to content
Snippets Groups Projects
Commit 693aca74 authored by Simonas Šerlinskas's avatar Simonas Šerlinskas
Browse files

Merge pull request #25 from mansimas/patch_docs

Patch docs
parents 62a00e71 a5e313a5
No related branches found
No related tags found
No related merge requests found
Showing
with 70 additions and 36 deletions
...@@ -10,7 +10,7 @@ A single-value metrics aggregation that computes the average of numeric values t ...@@ -10,7 +10,7 @@ A single-value metrics aggregation that computes the average of numeric values t
```JSON ```JSON
{ {
"aggregations": { "aggregations": {
"agg_avg_grade": { "avg_grade": {
"avg": { "avg": {
"field": "grade" "field": "grade"
} }
...@@ -31,4 +31,4 @@ $search->addAggregation($avgAggregation); ...@@ -31,4 +31,4 @@ $search->addAggregation($avgAggregation);
$queryArray = $search->toArray(); $queryArray = $search->toArray();
``` ```
[1]: https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-metrics-avg-aggregation.html [1]: https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-metrics-avg-aggregation.html
\ No newline at end of file
...@@ -9,7 +9,7 @@ A single-value metrics aggregation that calculates an approximate count of disti ...@@ -9,7 +9,7 @@ A single-value metrics aggregation that calculates an approximate count of disti
```JSON ```JSON
{ {
"aggregations" : { "aggregations" : {
"agg_author_count" : { "author_count" : {
"cardinality" : { "cardinality" : {
"field" : "author" "field" : "author"
} }
...@@ -21,7 +21,8 @@ A single-value metrics aggregation that calculates an approximate count of disti ...@@ -21,7 +21,8 @@ A single-value metrics aggregation that calculates an approximate count of disti
And now the query via DSL: And now the query via DSL:
```php ```php
$cardinalityAggregation = new CardinalityAggregation('author_count', 'author'); $cardinalityAggregation = new CardinalityAggregation('author_count');
$cardinalityAggregation->setField('author');
$search = new Search(); $search = new Search();
$search->addAggregation($cardinalityAggregation); $search->addAggregation($cardinalityAggregation);
......
...@@ -10,12 +10,12 @@ document types to buckets on child documents. ...@@ -10,12 +10,12 @@ document types to buckets on child documents.
```JSON ```JSON
{ {
"aggregations": { "aggregations": {
"agg_author_count": { "author_count": {
"children": { "children": {
"type": "answer" "type": "answer"
}, },
"aggregations": { "aggregations": {
"agg_top_names": { "top_names": {
"terms": { "terms": {
"field": "owner.display_name" "field": "owner.display_name"
} }
......
...@@ -9,13 +9,13 @@ A range aggregation that is dedicated for date values. ...@@ -9,13 +9,13 @@ A range aggregation that is dedicated for date values.
```JSON ```JSON
{ {
"aggregations": { "aggregations": {
"agg_range": { "range": {
"date_range": { "date_range": {
"field": "date", "field": "date",
"format": "MM-yyy", "format": "MM-yyy",
"ranges": [ "ranges": [
{ "to": "now-10M/M" }, { "to": "now-10M/M" },
{ "from": "now-10M/M" } { "from": "now-10M/M" }
] ]
} }
} }
...@@ -31,9 +31,14 @@ $dateRangeAggregation->setField('date'); ...@@ -31,9 +31,14 @@ $dateRangeAggregation->setField('date');
$dateRangeAggregation->setFormat('MM-yyy'); $dateRangeAggregation->setFormat('MM-yyy');
$dateRangeAggregation->addRange(null, 'now-10M/M'); $dateRangeAggregation->addRange(null, 'now-10M/M');
$dateRangeAggregation->addRange('now-10M/M', null); $dateRangeAggregation->addRange('now-10M/M', null);
$search = new Search();
$search->addAggregation($dateRangeAggregation);
$queryArray = $search->toArray();
``` ```
Or : Or :
```php ```php
$dateRangeAggregation = new DateRangeAggregation( $dateRangeAggregation = new DateRangeAggregation(
...@@ -48,6 +53,8 @@ $dateRangeAggregation = new DateRangeAggregation( ...@@ -48,6 +53,8 @@ $dateRangeAggregation = new DateRangeAggregation(
$search = new Search(); $search = new Search();
$search->addAggregation($dateRangeAggregation); $search->addAggregation($dateRangeAggregation);
$queryArray = $search->toArray();
``` ```
[1]: https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-bucket-daterange-aggregation.html [1]: https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-bucket-daterange-aggregation.html
...@@ -9,7 +9,7 @@ A multi-value metrics aggregation that computes stats over numeric values extrac ...@@ -9,7 +9,7 @@ A multi-value metrics aggregation that computes stats over numeric values extrac
```JSON ```JSON
{ {
"aggregations" : { "aggregations" : {
"agg_grades_stats" : { "grades_stats" : {
"extended_stats" : { "field" : "grade" } "extended_stats" : { "field" : "grade" }
} }
} }
......
...@@ -11,10 +11,10 @@ context to a specific set of documents. ...@@ -11,10 +11,10 @@ context to a specific set of documents.
```JSON ```JSON
{ {
"aggregations" : { "aggregations" : {
"agg_red_products" : { "grades_stats" : {
"filter" : { "term": { "color": "red" } }, "filter" : { "term": { "color": "red" } },
"aggs" : { "aggregations" : {
"agg_avg_price" : { "avg" : { "field" : "price" } } "avg_price" : { "avg" : { "field" : "price" } }
} }
} }
} }
......
...@@ -14,15 +14,15 @@ in exception. ...@@ -14,15 +14,15 @@ in exception.
```JSON ```JSON
{ {
"aggregations" : { "aggregations" : {
"agg_messages" : { "grades_stats" : {
"filters" : { "filters" : {
"filters" : { "filters" : {
"errors" : { "term" : { "body" : "error" }}, "error" : { "term" : { "body" : "error" }},
"warnings" : { "term" : { "body" : "warning" }} "warning" : { "term" : { "body" : "warning" }}
} }
}, },
"aggregations" : { "aggregations" : {
"agg_monthly" : { "monthly" : {
"histogram" : { "histogram" : {
"field" : "timestamp", "field" : "timestamp",
"interval" : "1M" "interval" : "1M"
...@@ -60,6 +60,31 @@ $queryArray = $search->toArray(); ...@@ -60,6 +60,31 @@ $queryArray = $search->toArray();
## Anonymous example ## 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 ```php
$errorTermFilter = new TermFilter('body', 'error'); $errorTermFilter = new TermFilter('body', 'error');
$warningTermFilter = new TermFilter('body', 'warning'); $warningTermFilter = new TermFilter('body', 'warning');
...@@ -83,4 +108,4 @@ $search->addAggregation($filterAggregation); ...@@ -83,4 +108,4 @@ $search->addAggregation($filterAggregation);
$queryArray = $search->toArray(); $queryArray = $search->toArray();
``` ```
[1]: https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-bucket-filters-aggregation.html [1]: https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-bucket-filters-aggregation.html
\ No newline at end of file
...@@ -9,7 +9,7 @@ A metric aggregation that computes the bounding box containing all geo_point val ...@@ -9,7 +9,7 @@ A metric aggregation that computes the bounding box containing all geo_point val
```JSON ```JSON
{ {
"aggregations" : { "aggregations" : {
"agg_viewport" : { "viewport" : {
"geo_bounds" : { "geo_bounds" : {
"field" : "location", "field" : "location",
"wrap_longitude" : true "wrap_longitude" : true
......
...@@ -10,7 +10,7 @@ that represent cells in a grid. ...@@ -10,7 +10,7 @@ that represent cells in a grid.
```JSON ```JSON
{ {
"aggregations" : { "aggregations" : {
"agg_GrainGeoHashGrid" : { "GrainGeoHashGrid" : {
"geohash_grid" : { "geohash_grid" : {
"field" : "location", "field" : "location",
"precision" : 3 "precision" : 3
......
...@@ -11,10 +11,10 @@ you’re searching on, but is **not influenced** by the search query itself. ...@@ -11,10 +11,10 @@ you’re searching on, but is **not influenced** by the search query itself.
```JSON ```JSON
{ {
"aggregations": { "aggregations": {
"agg_all_products": { "all_products": {
"global": {}, "global": {},
"aggregations": { "aggregations": {
"agg_avg_price": { "avg_price": {
"avg": { "avg": {
"field": "price" "field": "price"
} }
......
...@@ -10,7 +10,7 @@ the documents. It dynamically builds fixed size (a.k.a. interval) buckets over t ...@@ -10,7 +10,7 @@ the documents. It dynamically builds fixed size (a.k.a. interval) buckets over t
```JSON ```JSON
{ {
"aggregations": { "aggregations": {
"agg_prices": { "prices": {
"histogram": { "histogram": {
"field": "price", "field": "price",
"interval": 50 "interval": 50
......
...@@ -10,7 +10,7 @@ range aggregation for IPv4 typed fields. ...@@ -10,7 +10,7 @@ range aggregation for IPv4 typed fields.
```JSON ```JSON
{ {
"aggregations" : { "aggregations" : {
"agg_ip_range" : { "ip_range" : {
"ip_range" : { "ip_range" : {
"field" : "ip", "field" : "ip",
"ranges" : [ "ranges" : [
......
...@@ -10,7 +10,7 @@ in the current document set context that are missing a field value. ...@@ -10,7 +10,7 @@ in the current document set context that are missing a field value.
```JSON ```JSON
{ {
"aggregations" : { "aggregations" : {
"agg_products_without_a_price" : { "products_without_a_price" : {
"missing" : { "field" : "price" } "missing" : { "field" : "price" }
} }
} }
......
...@@ -9,12 +9,12 @@ A special single bucket aggregation that enables aggregating nested documents. ...@@ -9,12 +9,12 @@ A special single bucket aggregation that enables aggregating nested documents.
```JSON ```JSON
{ {
"aggregations" : { "aggregations" : {
"agg_resellers" : { "resellers" : {
"nested" : { "nested" : {
"path" : "resellers" "path" : "resellers"
}, },
"aggregations" : { "aggregations" : {
"agg_min_price" : { "min" : { "field" : "resellers.price" } } "min_price" : { "min" : { "field" : "resellers.price" } }
} }
} }
} }
......
...@@ -10,7 +10,7 @@ ranks over numeric values extracted from the aggregated documents. ...@@ -10,7 +10,7 @@ ranks over numeric values extracted from the aggregated documents.
```JSON ```JSON
{ {
"aggregations" : { "aggregations" : {
"agg_load_time_outlier" : { "load_time_outlier" : {
"percentile_ranks" : { "percentile_ranks" : {
"field" : "load_time", "field" : "load_time",
"values" : [15, 30] "values" : [15, 30]
......
...@@ -10,7 +10,7 @@ numeric values extracted from the aggregated documents. ...@@ -10,7 +10,7 @@ numeric values extracted from the aggregated documents.
```JSON ```JSON
{ {
"aggregations" : { "aggregations" : {
"agg_load_time_outlier" : { "load_time_outlier" : {
"percentiles" : { "percentiles" : {
"field" : "load_time" "field" : "load_time"
} }
......
...@@ -10,9 +10,10 @@ ranges - each representing a bucket. ...@@ -10,9 +10,10 @@ ranges - each representing a bucket.
```JSON ```JSON
{ {
"aggs" : { "aggs" : {
"agg_price_ranges" : { "price_ranges" : {
"range" : { "range" : {
"field" : "price", "field" : "price",
"keyed" : false,
"ranges" : [ "ranges" : [
{ "to" : 50 }, { "to" : 50 },
{ "from" : 50, "to" : 100 }, { "from" : 50, "to" : 100 },
......
...@@ -9,17 +9,17 @@ A special single bucket aggregation that enables aggregating on parent docs from ...@@ -9,17 +9,17 @@ A special single bucket aggregation that enables aggregating on parent docs from
```JSON ```JSON
{ {
"aggregations": { "aggregations": {
"agg_comments": { "comments": {
"nested": { "nested": {
"path": "comments" "path": "comments"
}, },
"aggregations": { "aggregations": {
"agg_top_usernames": { "top_usernames": {
"terms": { "terms": {
"field": "comments.username" "field": "comments.username"
}, },
"aggregations": { "aggregations": {
"agg_comment_to_issue": { "comment_to_issue": {
"reverse_nested": {}, "reverse_nested": {},
"aggregations": { "aggregations": {
"top_tags_per_comment": { "top_tags_per_comment": {
......
...@@ -10,7 +10,7 @@ values extracted from the aggregated documents. ...@@ -10,7 +10,7 @@ values extracted from the aggregated documents.
```JSON ```JSON
{ {
"aggregations" : { "aggregations" : {
"agg_grades_stats" : { "stats" : { "field" : "grade" } } "grades_stats" : { "stats" : { "field" : "grade" } }
} }
} }
``` ```
......
...@@ -9,7 +9,7 @@ A single-value metrics aggregation that sums up numeric values that are extracte ...@@ -9,7 +9,7 @@ A single-value metrics aggregation that sums up numeric values that are extracte
```JSON ```JSON
{ {
"aggregations" : { "aggregations" : {
"agg_intraday_return" : { "sum" : { "field" : "change" } } "intraday_return" : { "sum" : { "field" : "change" } }
} }
} }
``` ```
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment