Skip to content

Commit

Permalink
[Docs] Convert remaining code snippets in docs (#26422)
Browse files Browse the repository at this point in the history
This commit converts the last remaining code snippets so that they are
now testable.
  • Loading branch information
tlrx authored Aug 30, 2017
1 parent 34a6c7a commit 643eb28
Show file tree
Hide file tree
Showing 9 changed files with 675 additions and 209 deletions.
15 changes: 0 additions & 15 deletions docs/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -19,21 +19,6 @@

apply plugin: 'elasticsearch.docs-test'

/* List of files that have snippets that probably should be converted to
* `// CONSOLE` and `// TESTRESPONSE` but have yet to be converted. Try and
* only remove entries from this list. When it is empty we'll remove it
* entirely and have a party! There will be cake and everything.... */
buildRestTests.expectedUnconvertedCandidates = [
'reference/aggregations/bucket/nested-aggregation.asciidoc',
'reference/aggregations/bucket/range-aggregation.asciidoc',
'reference/aggregations/bucket/reverse-nested-aggregation.asciidoc',
'reference/aggregations/bucket/significantterms-aggregation.asciidoc',
'reference/aggregations/bucket/terms-aggregation.asciidoc',
'reference/aggregations/matrix/stats-aggregation.asciidoc',
'reference/aggregations/metrics/tophits-aggregation.asciidoc',
'reference/cluster/allocation-explain.asciidoc',
]

integTestCluster {
setting 'script.max_compilations_per_minute', '1000'
/* Enable regexes in painless so our tests don't complain about example
Expand Down
28 changes: 19 additions & 9 deletions docs/reference/aggregations/bucket/nested-aggregation.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ price for the product. The mapping could look like:

[source,js]
--------------------------------------------------
PUT /index
{
...
"mappings": {
"product" : {
"properties" : {
"resellers" : { <1>
Expand All @@ -22,15 +22,18 @@ price for the product. The mapping could look like:
}
}
}
}
}
--------------------------------------------------

// CONSOLE
// TESTSETUP
<1> The `resellers` is an array that holds nested documents under the `product` object.

The following aggregations will return the minimum price products can be purchased in:

[source,js]
--------------------------------------------------
GET /_search
{
"query" : {
"match" : { "name" : "led tv" }
Expand All @@ -47,6 +50,9 @@ The following aggregations will return the minimum price products can be purchas
}
}
--------------------------------------------------
// CONSOLE
// TEST[s/GET \/_search/GET \/_search\?filter_path=aggregations/]
// TEST[s/^/PUT index\/product\/0\?refresh\n{"name":"led", "resellers": [{"name": "foo", "price": 350.00}, {"name": "bar", "price": 500.00}]}\n/]

As you can see above, the nested aggregation requires the `path` of the nested documents within the top level documents.
Then one can define any type of aggregation over these nested documents.
Expand All @@ -56,12 +62,16 @@ Response:
[source,js]
--------------------------------------------------
{
"aggregations": {
"resellers": {
"min_price": {
"value" : 350
}
}
...
"aggregations": {
"resellers": {
"doc_count": 0,
"min_price": {
"value": 350
}
}
}
}
--------------------------------------------------
// TESTRESPONSE[s/\.\.\.//]
// TESTRESPONSE[s/: [0-9]+/: $body.$_path/]
Loading

0 comments on commit 643eb28

Please sign in to comment.