CONSOLE-ify filter aggregation docs

This adds the `VIEW IN CONSOLE` and `COPY AS CURL` links to the
snippet and causes the build to execute the snippet as a test.

Relates to #18160
This commit is contained in:
Nik Everett 2017-01-23 01:32:56 -05:00
parent 40e2645177
commit a99bddcc7e
2 changed files with 10 additions and 8 deletions

View File

@ -25,7 +25,6 @@ apply plugin: 'elasticsearch.docs-test'
* entirely and have a party! There will be cake and everything.... */
buildRestTests.expectedUnconvertedCandidates = [
'reference/aggregations/bucket/diversified-sampler-aggregation.asciidoc',
'reference/aggregations/bucket/filter-aggregation.asciidoc',
'reference/aggregations/bucket/geodistance-aggregation.asciidoc',
'reference/aggregations/bucket/geohashgrid-aggregation.asciidoc',
'reference/aggregations/bucket/histogram-aggregation.asciidoc',

View File

@ -7,10 +7,11 @@ Example:
[source,js]
--------------------------------------------------
POST /sales/_search?size=0
{
"aggs" : {
"red_products" : {
"filter" : { "term": { "color": "red" } },
"t_shirts" : {
"filter" : { "term": { "type": "t-shirt" } },
"aggs" : {
"avg_price" : { "avg" : { "field" : "price" } }
}
@ -18,6 +19,8 @@ Example:
}
}
--------------------------------------------------
// CONSOLE
// TEST[setup:sales]
In the above example, we calculate the average price of all the products that are red.
@ -27,12 +30,12 @@ Response:
--------------------------------------------------
{
...
"aggs" : {
"red_products" : {
"doc_count" : 100,
"avg_price" : { "value" : 56.3 }
"aggregations" : {
"t_shirts" : {
"doc_count" : 3,
"avg_price" : { "value" : 128.33333333333334 }
}
}
}
--------------------------------------------------
// TESTRESPONSE[s/\.\.\./"took": $body.took,"timed_out": false,"_shards": $body._shards,"hits": $body.hits,/]