Browse Source

Docs: CONSOLE-ify value_count aggregation docs

Adds the `VIEW IN CONSOLE` and `COPY AS CURL` links to the snippets
in the `value_count` docs and causes the build to execute the snippets
for testing.

Release #18160
Nik Everett 8 years ago
parent
commit
da8740128b

+ 0 - 1
docs/build.gradle

@@ -48,7 +48,6 @@ buildRestTests.expectedUnconvertedCandidates = [
   'reference/aggregations/metrics/stats-aggregation.asciidoc',
   'reference/aggregations/metrics/sum-aggregation.asciidoc',
   'reference/aggregations/metrics/tophits-aggregation.asciidoc',
-  'reference/aggregations/metrics/valuecount-aggregation.asciidoc',
   'reference/aggregations/pipeline.asciidoc',
   'reference/aggregations/pipeline/avg-bucket-aggregation.asciidoc',
   'reference/aggregations/pipeline/bucket-script-aggregation.asciidoc',

+ 19 - 15
docs/reference/aggregations/metrics/valuecount-aggregation.asciidoc

@@ -8,12 +8,15 @@ one might be interested in the number of values the average is computed over.
 
 [source,js]
 --------------------------------------------------
+POST /sales/_search?size=0
 {
     "aggs" : {
-        "grades_count" : { "value_count" : { "field" : "grade" } }
+        "types_count" : { "value_count" : { "field" : "type" } }
     }
 }
 --------------------------------------------------
+// CONSOLE
+// TEST[setup:sales]
 
 Response:
 
@@ -21,14 +24,14 @@ Response:
 --------------------------------------------------
 {
     ...
-
     "aggregations": {
-        "grades_count": {
-            "value": 10
+        "types_count": {
+            "value": 7
         }
     }
 }
 --------------------------------------------------
+// TESTRESPONSE[s/\.\.\./"took": $body.took,"timed_out": false,"_shards": $body._shards,"hits": $body.hits,/]
 
 The name of the aggregation (`grades_count` above) also serves as the key by which the aggregation result can be
 retrieved from the returned response.
@@ -39,36 +42,35 @@ Counting the values generated by a script:
 
 [source,js]
 --------------------------------------------------
+POST /sales/_search?size=0
 {
-    ...,
-
     "aggs" : {
-        "grades_count" : { 
-            "value_count" : { 
+        "type_count" : {
+            "value_count" : {
                 "script" : {
-                    "inline" : "doc['grade'].value",
-                    "lang" : "painless"
+                    "inline" : "doc['type'].value"
                 }
             }
         }
     }
 }
 --------------------------------------------------
+// CONSOLE
+// TEST[setup:sales]
 
 This will interpret the `script` parameter as an `inline` script with the `painless` script language and no script parameters. To use a file script use the following syntax:
 
 [source,js]
 --------------------------------------------------
+POST /sales/_search?size=0
 {
-    ...,
-
     "aggs" : {
-        "grades_count" : { 
-            "value_count" : { 
+        "grades_count" : {
+            "value_count" : {
                 "script" : {
                     "file": "my_script",
                     "params" : {
-                        "field" : "grade"
+                        "field" : "type"
                     }
                 }
             }
@@ -76,5 +78,7 @@ This will interpret the `script` parameter as an `inline` script with the `painl
     }
 }
 --------------------------------------------------
+// CONSOLE
+// TEST[setup:sales]
 
 TIP: for indexed scripts replace the `file` parameter with an `id` parameter.