Skip to content

Commit 643eb28

Browse files
authored
[Docs] Convert remaining code snippets in docs (#26422)
This commit converts the last remaining code snippets so that they are now testable.
1 parent 34a6c7a commit 643eb28

9 files changed

+675
-209
lines changed

docs/build.gradle

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -19,21 +19,6 @@
1919

2020
apply plugin: 'elasticsearch.docs-test'
2121

22-
/* List of files that have snippets that probably should be converted to
23-
* `// CONSOLE` and `// TESTRESPONSE` but have yet to be converted. Try and
24-
* only remove entries from this list. When it is empty we'll remove it
25-
* entirely and have a party! There will be cake and everything.... */
26-
buildRestTests.expectedUnconvertedCandidates = [
27-
'reference/aggregations/bucket/nested-aggregation.asciidoc',
28-
'reference/aggregations/bucket/range-aggregation.asciidoc',
29-
'reference/aggregations/bucket/reverse-nested-aggregation.asciidoc',
30-
'reference/aggregations/bucket/significantterms-aggregation.asciidoc',
31-
'reference/aggregations/bucket/terms-aggregation.asciidoc',
32-
'reference/aggregations/matrix/stats-aggregation.asciidoc',
33-
'reference/aggregations/metrics/tophits-aggregation.asciidoc',
34-
'reference/cluster/allocation-explain.asciidoc',
35-
]
36-
3722
integTestCluster {
3823
setting 'script.max_compilations_per_minute', '1000'
3924
/* Enable regexes in painless so our tests don't complain about example

docs/reference/aggregations/bucket/nested-aggregation.asciidoc

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@ price for the product. The mapping could look like:
88

99
[source,js]
1010
--------------------------------------------------
11+
PUT /index
1112
{
12-
...
13-
13+
"mappings": {
1414
"product" : {
1515
"properties" : {
1616
"resellers" : { <1>
@@ -22,15 +22,18 @@ price for the product. The mapping could look like:
2222
}
2323
}
2424
}
25+
}
2526
}
2627
--------------------------------------------------
27-
28+
// CONSOLE
29+
// TESTSETUP
2830
<1> The `resellers` is an array that holds nested documents under the `product` object.
2931

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

3234
[source,js]
3335
--------------------------------------------------
36+
GET /_search
3437
{
3538
"query" : {
3639
"match" : { "name" : "led tv" }
@@ -47,6 +50,9 @@ The following aggregations will return the minimum price products can be purchas
4750
}
4851
}
4952
--------------------------------------------------
53+
// CONSOLE
54+
// TEST[s/GET \/_search/GET \/_search\?filter_path=aggregations/]
55+
// TEST[s/^/PUT index\/product\/0\?refresh\n{"name":"led", "resellers": [{"name": "foo", "price": 350.00}, {"name": "bar", "price": 500.00}]}\n/]
5056

5157
As you can see above, the nested aggregation requires the `path` of the nested documents within the top level documents.
5258
Then one can define any type of aggregation over these nested documents.
@@ -56,12 +62,16 @@ Response:
5662
[source,js]
5763
--------------------------------------------------
5864
{
59-
"aggregations": {
60-
"resellers": {
61-
"min_price": {
62-
"value" : 350
63-
}
64-
}
65+
...
66+
"aggregations": {
67+
"resellers": {
68+
"doc_count": 0,
69+
"min_price": {
70+
"value": 350
71+
}
6572
}
73+
}
6674
}
6775
--------------------------------------------------
76+
// TESTRESPONSE[s/\.\.\.//]
77+
// TESTRESPONSE[s/: [0-9]+/: $body.$_path/]

0 commit comments

Comments
 (0)