OpenSearch/docs/reference/aggregations/bucket
Nik Everett 6d2c40e546 Enforce that responses in docs are valid json (#26249)
All of the snippets in our docs marked with `// TESTRESPONSE` are
checked against the response from Elasticsearch but, due to the
way they are implemented they are actually parsed as YAML instead
of JSON. Luckilly, all valid JSON is valid YAML! Unfurtunately
that means that invalid JSON has snuck into the exmples!

This adds a step during the build to parse them as JSON and fail
the build if they don't parse.

But no! It isn't quite that simple. The displayed text of some of
these responses looks like:
```
{
    ...
    "aggregations": {
        "range": {
            "buckets": [
                {
                    "to": 1.4436576E12,
                    "to_as_string": "10-2015",
                    "doc_count": 7,
                    "key": "*-10-2015"
                },
                {
                    "from": 1.4436576E12,
                    "from_as_string": "10-2015",
                    "doc_count": 0,
                    "key": "10-2015-*"
                }
            ]
        }
    }
}
```

Note the `...` which isn't valid json but we like it anyway and want
it in the output. We use substitution rules to convert the `...`
into the response we expect. That yields a response that looks like:
```
{
    "took": $body.took,"timed_out": false,"_shards": $body._shards,"hits": $body.hits,
    "aggregations": {
        "range": {
            "buckets": [
                {
                    "to": 1.4436576E12,
                    "to_as_string": "10-2015",
                    "doc_count": 7,
                    "key": "*-10-2015"
                },
                {
                    "from": 1.4436576E12,
                    "from_as_string": "10-2015",
                    "doc_count": 0,
                    "key": "10-2015-*"
                }
            ]
        }
    }
}
```

That is what the tests consume but it isn't valid JSON! Oh no! We don't
want to go update all the substitution rules because that'd be huge and,
ultimately, wouldn't buy much. So we quote the `$body.took` bits before
parsing the JSON.

Note the responses that we use for the `_cat` APIs are all converted into
regexes and there is no expectation that they are valid JSON.

Closes #26233
2017-08-17 09:02:10 -04:00
..
adjacency-matrix-aggregation.asciidoc Update experimental labels in the docs (#25727) 2017-07-18 14:06:22 +02:00
children-aggregation.asciidoc Add a shard filter search phase to pre-filter shards based on query rewriting (#25658) 2017-07-12 22:19:20 +02:00
datehistogram-aggregation.asciidoc Document aggregating by day of the week (#25602) 2017-07-07 14:16:53 -04:00
daterange-aggregation.asciidoc Update aggs reference documentation for 'keyed' options (#23758) 2017-04-18 15:57:50 +02:00
diversified-sampler-aggregation.asciidoc Enforce that responses in docs are valid json (#26249) 2017-08-17 09:02:10 -04:00
filter-aggregation.asciidoc Update filter-aggregation.asciidoc (#24138) 2017-04-17 18:46:13 -04:00
filters-aggregation.asciidoc Fix `other_bucket` on the `filters` agg to be enabled if a key is set. (#21994) 2016-12-09 09:48:48 +01:00
geodistance-aggregation.asciidoc Update aggs reference documentation for 'keyed' options (#23758) 2017-04-18 15:57:50 +02:00
geohashgrid-aggregation.asciidoc CONSOLEify geo aggregation docs 2017-03-30 21:28:52 -04:00
global-aggregation.asciidoc CONSOLE-ify global-aggregation.asciidoc 2017-01-20 14:36:51 -05:00
histogram-aggregation.asciidoc Compound order for histogram aggregations. (#22343) 2017-05-11 18:06:26 +01:00
iprange-aggregation.asciidoc CONSOLEify ip-range bucket agg docs 2017-08-03 17:19:54 -04:00
missing-aggregation.asciidoc CONSOLEify some more aggregation docs 2017-05-16 17:25:24 -04:00
nested-aggregation.asciidoc Document 5.0 mapping changes. 2016-03-22 16:22:58 +01:00
range-aggregation.asciidoc Scripting: Change keys for inline/stored scripts to source/id (#25127) 2017-06-09 08:29:25 -07:00
reverse-nested-aggregation.asciidoc Docs: Add comma to reverse nested agg snippet 2017-03-17 14:07:18 +01:00
sampler-aggregation.asciidoc Update experimental labels in the docs (#25727) 2017-07-18 14:06:22 +02:00
significantterms-aggregation.asciidoc Update experimental labels in the docs (#25727) 2017-07-18 14:06:22 +02:00
significanttext-aggregation.asciidoc SignificantText aggregation - like significant_terms, but for text (#24432) 2017-05-24 13:46:43 +01:00
terms-aggregation.asciidoc Update experimental labels in the docs (#25727) 2017-07-18 14:06:22 +02:00