浏览代码

[DOCS] Reformat agg snippets to use two-space indents (#59912)

James Rodewig 5 年之前
父节点
当前提交
2c5d6e9c95
共有 62 个文件被更改,包括 3991 次插入3991 次删除
  1. 52 52
      docs/reference/aggregations/bucket/autodatehistogram-aggregation.asciidoc
  2. 308 308
      docs/reference/aggregations/bucket/composite-aggregation.asciidoc
  3. 101 101
      docs/reference/aggregations/bucket/datehistogram-aggregation.asciidoc
  4. 86 86
      docs/reference/aggregations/bucket/daterange-aggregation.asciidoc
  5. 81 81
      docs/reference/aggregations/bucket/diversified-sampler-aggregation.asciidoc
  6. 13 13
      docs/reference/aggregations/bucket/filter-aggregation.asciidoc
  7. 131 131
      docs/reference/aggregations/bucket/geodistance-aggregation.asciidoc
  8. 116 116
      docs/reference/aggregations/bucket/geohashgrid-aggregation.asciidoc
  9. 96 96
      docs/reference/aggregations/bucket/geotilegrid-aggregation.asciidoc
  10. 22 22
      docs/reference/aggregations/bucket/global-aggregation.asciidoc
  11. 156 156
      docs/reference/aggregations/bucket/histogram-aggregation.asciidoc
  12. 108 108
      docs/reference/aggregations/bucket/iprange-aggregation.asciidoc
  13. 9 9
      docs/reference/aggregations/bucket/missing-aggregation.asciidoc
  14. 21 21
      docs/reference/aggregations/bucket/nested-aggregation.asciidoc
  15. 169 169
      docs/reference/aggregations/bucket/range-aggregation.asciidoc
  16. 22 22
      docs/reference/aggregations/bucket/range-field-note.asciidoc
  17. 71 71
      docs/reference/aggregations/bucket/rare-terms-aggregation.asciidoc
  18. 11 11
      docs/reference/aggregations/bucket/reverse-nested-aggregation.asciidoc
  19. 79 79
      docs/reference/aggregations/bucket/sampler-aggregation.asciidoc
  20. 76 76
      docs/reference/aggregations/bucket/significantterms-aggregation.asciidoc
  21. 39 39
      docs/reference/aggregations/bucket/significanttext-aggregation.asciidoc
  22. 202 202
      docs/reference/aggregations/bucket/terms-aggregation.asciidoc
  23. 24 24
      docs/reference/aggregations/bucket/variablewidthhistogram-aggregation.asciidoc
  24. 49 49
      docs/reference/aggregations/matrix/stats-aggregation.asciidoc
  25. 53 53
      docs/reference/aggregations/metrics/avg-aggregation.asciidoc
  26. 60 60
      docs/reference/aggregations/metrics/boxplot-aggregation.asciidoc
  27. 44 44
      docs/reference/aggregations/metrics/cardinality-aggregation.asciidoc
  28. 79 79
      docs/reference/aggregations/metrics/extendedstats-aggregation.asciidoc
  29. 54 54
      docs/reference/aggregations/metrics/geobounds-aggregation.asciidoc
  30. 90 90
      docs/reference/aggregations/metrics/geocentroid-aggregation.asciidoc
  31. 51 51
      docs/reference/aggregations/metrics/max-aggregation.asciidoc
  32. 43 43
      docs/reference/aggregations/metrics/min-aggregation.asciidoc
  33. 121 121
      docs/reference/aggregations/metrics/percentile-aggregation.asciidoc
  34. 84 84
      docs/reference/aggregations/metrics/percentile-rank-aggregation.asciidoc
  35. 51 51
      docs/reference/aggregations/metrics/scripted-metric-aggregation.asciidoc
  36. 51 51
      docs/reference/aggregations/metrics/stats-aggregation.asciidoc
  37. 93 93
      docs/reference/aggregations/metrics/string-stats-aggregation.asciidoc
  38. 82 82
      docs/reference/aggregations/metrics/sum-aggregation.asciidoc
  39. 66 66
      docs/reference/aggregations/metrics/t-test-aggregation.asciidoc
  40. 58 58
      docs/reference/aggregations/metrics/tophits-aggregation.asciidoc
  41. 34 34
      docs/reference/aggregations/metrics/valuecount-aggregation.asciidoc
  42. 58 58
      docs/reference/aggregations/metrics/weighted-avg-aggregation.asciidoc
  43. 43 43
      docs/reference/aggregations/misc.asciidoc
  44. 71 71
      docs/reference/aggregations/pipeline.asciidoc
  45. 3 3
      docs/reference/aggregations/pipeline/avg-bucket-aggregation.asciidoc
  46. 43 43
      docs/reference/aggregations/pipeline/bucket-script-aggregation.asciidoc
  47. 28 28
      docs/reference/aggregations/pipeline/bucket-selector-aggregation.asciidoc
  48. 46 46
      docs/reference/aggregations/pipeline/bucket-sort-aggregation.asciidoc
  49. 46 46
      docs/reference/aggregations/pipeline/cumulative-cardinality-aggregation.asciidoc
  50. 22 22
      docs/reference/aggregations/pipeline/cumulative-sum-aggregation.asciidoc
  51. 63 63
      docs/reference/aggregations/pipeline/derivative-aggregation.asciidoc
  52. 22 22
      docs/reference/aggregations/pipeline/extended-stats-bucket-aggregation.asciidoc
  53. 11 11
      docs/reference/aggregations/pipeline/inference-bucket-aggregation.asciidoc
  54. 22 22
      docs/reference/aggregations/pipeline/max-bucket-aggregation.asciidoc
  55. 22 22
      docs/reference/aggregations/pipeline/min-bucket-aggregation.asciidoc
  56. 214 214
      docs/reference/aggregations/pipeline/movfn-aggregation.asciidoc
  57. 25 25
      docs/reference/aggregations/pipeline/moving-percentiles-aggregation.asciidoc
  58. 25 25
      docs/reference/aggregations/pipeline/normalize-aggregation.asciidoc
  59. 23 23
      docs/reference/aggregations/pipeline/percentiles-bucket-aggregation.asciidoc
  60. 4 4
      docs/reference/aggregations/pipeline/serial-diff-aggregation.asciidoc
  61. 22 22
      docs/reference/aggregations/pipeline/stats-bucket-aggregation.asciidoc
  62. 22 22
      docs/reference/aggregations/pipeline/sum-bucket-aggregation.asciidoc

+ 52 - 52
docs/reference/aggregations/bucket/autodatehistogram-aggregation.asciidoc

@@ -14,14 +14,14 @@ Requesting a target of 10 buckets.
 --------------------------------------------------
 POST /sales/_search?size=0
 {
-    "aggs" : {
-        "sales_over_time" : {
-            "auto_date_histogram" : {
-                "field" : "date",
-                "buckets" : 10
-            }
-        }
+  "aggs": {
+    "sales_over_time": {
+      "auto_date_histogram": {
+        "field": "date",
+        "buckets": 10
+      }
     }
+  }
 }
 --------------------------------------------------
 // TEST[setup:sales]
@@ -40,15 +40,15 @@ TIP: If no `format` is specified, then it will use the first date
 --------------------------------------------------
 POST /sales/_search?size=0
 {
-    "aggs" : {
-        "sales_over_time" : {
-            "auto_date_histogram" : {
-                "field" : "date",
-                "buckets" : 5,
-                "format" : "yyyy-MM-dd" <1>
-            }
-        }
+  "aggs": {
+    "sales_over_time": {
+      "auto_date_histogram": {
+        "field": "date",
+        "buckets": 5,
+        "format": "yyyy-MM-dd" <1>
+      }
     }
+  }
 }
 --------------------------------------------------
 // TEST[setup:sales]
@@ -60,29 +60,29 @@ Response:
 [source,console-result]
 --------------------------------------------------
 {
-    ...
-    "aggregations": {
-        "sales_over_time": {
-            "buckets": [
-                {
-                    "key_as_string": "2015-01-01",
-                    "key": 1420070400000,
-                    "doc_count": 3
-                },
-                {
-                    "key_as_string": "2015-02-01",
-                    "key": 1422748800000,
-                    "doc_count": 2
-                },
-                {
-                    "key_as_string": "2015-03-01",
-                    "key": 1425168000000,
-                    "doc_count": 2
-                }
-            ],
-            "interval": "1M"
+  ...
+  "aggregations": {
+    "sales_over_time": {
+      "buckets": [
+        {
+          "key_as_string": "2015-01-01",
+          "key": 1420070400000,
+          "doc_count": 3
+        },
+        {
+          "key_as_string": "2015-02-01",
+          "key": 1422748800000,
+          "doc_count": 2
+        },
+        {
+          "key_as_string": "2015-03-01",
+          "key": 1425168000000,
+          "doc_count": 2
         }
+      ],
+      "interval": "1M"
     }
+  }
 }
 --------------------------------------------------
 // TESTRESPONSE[s/\.\.\./"took": $body.took,"timed_out": false,"_shards": $body._shards,"hits": $body.hits,/]
@@ -273,15 +273,15 @@ The accepted units for `minimum_interval` are:
 --------------------------------------------------
 POST /sales/_search?size=0
 {
-    "aggs" : {
-        "sale_date" : {
-             "auto_date_histogram" : {
-                 "field" : "date",
-                 "buckets": 10,
-                 "minimum_interval": "minute"
-             }
-         }
+  "aggs": {
+    "sale_date": {
+      "auto_date_histogram": {
+        "field": "date",
+        "buckets": 10,
+        "minimum_interval": "minute"
+      }
     }
+  }
 }
 --------------------------------------------------
 // TEST[setup:sales]
@@ -296,15 +296,15 @@ had a value.
 --------------------------------------------------
 POST /sales/_search?size=0
 {
-    "aggs" : {
-        "sale_date" : {
-             "auto_date_histogram" : {
-                 "field" : "date",
-                 "buckets": 10,
-                 "missing": "2000/01/01" <1>
-             }
-         }
+  "aggs": {
+    "sale_date": {
+      "auto_date_histogram": {
+        "field": "date",
+        "buckets": 10,
+        "missing": "2000/01/01" <1>
+      }
     }
+  }
 }
 --------------------------------------------------
 // TEST[setup:sales]

+ 308 - 308
docs/reference/aggregations/bucket/composite-aggregation.asciidoc

@@ -75,8 +75,8 @@ For instance the following document:
 [source,js]
 --------------------------------------------------
 {
-    "keyword": ["foo", "bar"],
-    "number": [23, 65, 76]
+  "keyword": ["foo", "bar"],
+  "number": [23, 65, 76]
 }
 --------------------------------------------------
 // NOTCONSOLE
@@ -117,16 +117,16 @@ Example:
 --------------------------------------------------
 GET /_search
 {
-    "size": 0,
-    "aggs" : {
-        "my_buckets": {
-            "composite" : {
-                "sources" : [
-                    { "product": { "terms" : { "field": "product" } } }
-                ]
-            }
-        }
-     }
+  "size": 0,
+  "aggs": {
+    "my_buckets": {
+      "composite": {
+        "sources": [
+          { "product": { "terms": { "field": "product" } } }
+        ]
+      }
+    }
+  }
 }
 --------------------------------------------------
 
@@ -136,25 +136,25 @@ Like the `terms` aggregation it is also possible to use a script to create the v
 --------------------------------------------------
 GET /_search
 {
-    "size": 0,
-    "aggs" : {
-        "my_buckets": {
-            "composite" : {
-                "sources" : [
-                    {
-                        "product": {
-                            "terms" : {
-                                "script" : {
-                                    "source": "doc['product'].value",
-                                    "lang": "painless"
-                                }
-                            }
-                        }
-                    }
-                ]
+  "size": 0,
+  "aggs": {
+    "my_buckets": {
+      "composite": {
+        "sources": [
+          {
+            "product": {
+              "terms": {
+                "script": {
+                  "source": "doc['product'].value",
+                  "lang": "painless"
+                }
+              }
             }
-        }
+          }
+        ]
+      }
     }
+  }
 }
 --------------------------------------------------
 
@@ -172,16 +172,16 @@ Example:
 --------------------------------------------------
 GET /_search
 {
-    "size": 0,
-    "aggs" : {
-        "my_buckets": {
-            "composite" : {
-                "sources" : [
-                    { "histo": { "histogram" : { "field": "price", "interval": 5 } } }
-                ]
-            }
-        }
+  "size": 0,
+  "aggs": {
+    "my_buckets": {
+      "composite": {
+        "sources": [
+          { "histo": { "histogram": { "field": "price", "interval": 5 } } }
+        ]
+      }
     }
+  }
 }
 --------------------------------------------------
 
@@ -191,26 +191,26 @@ The values are built from a numeric field or a script that return numerical valu
 --------------------------------------------------
 GET /_search
 {
-    "size": 0,
-    "aggs" : {
-        "my_buckets": {
-            "composite" : {
-                "sources" : [
-                    {
-                        "histo": {
-                            "histogram" : {
-                                "interval": 5,
-                                "script" : {
-                                    "source": "doc['price'].value",
-                                    "lang": "painless"
-                                }
-                            }
-                        }
-                    }
-                ]
+  "size": 0,
+  "aggs": {
+    "my_buckets": {
+      "composite": {
+        "sources": [
+          {
+            "histo": {
+              "histogram": {
+                "interval": 5,
+                "script": {
+                  "source": "doc['price'].value",
+                  "lang": "painless"
+                }
+              }
             }
-        }
+          }
+        ]
+      }
     }
+  }
 }
 --------------------------------------------------
 
@@ -224,16 +224,16 @@ is specified by date/time expression:
 --------------------------------------------------
 GET /_search
 {
-    "size": 0,
-    "aggs" : {
-        "my_buckets": {
-            "composite" : {
-                "sources" : [
-                    { "date": { "date_histogram" : { "field": "timestamp", "calendar_interval": "1d" } } }
-                ]
-            }
-        }
+  "size": 0,
+  "aggs": {
+    "my_buckets": {
+      "composite": {
+        "sources": [
+          { "date": { "date_histogram": { "field": "timestamp", "calendar_interval": "1d" } } }
+        ]
+      }
     }
+  }
 }
 --------------------------------------------------
 
@@ -254,24 +254,24 @@ the format specified with the format parameter:
 --------------------------------------------------
 GET /_search
 {
-    "size": 0,
-    "aggs" : {
-        "my_buckets": {
-            "composite" : {
-                "sources" : [
-                    {
-                        "date": {
-                            "date_histogram" : {
-                                "field": "timestamp",
-                                "calendar_interval": "1d",
-                                "format": "yyyy-MM-dd" <1>
-                            }
-                        }
-                    }
-                ]
+  "size": 0,
+  "aggs": {
+    "my_buckets": {
+      "composite": {
+        "sources": [
+          {
+            "date": {
+              "date_histogram": {
+                "field": "timestamp",
+                "calendar_interval": "1d",
+                "format": "yyyy-MM-dd"         <1>
+              }
             }
-        }
+          }
+        ]
+      }
     }
+  }
 }
 --------------------------------------------------
 
@@ -367,16 +367,16 @@ to the user-specified precision.
 --------------------------------------------------
 GET /_search
 {
-    "size": 0,
-    "aggs" : {
-        "my_buckets": {
-            "composite" : {
-                "sources" : [
-                    { "tile": { "geotile_grid" : { "field": "location", "precision": 8 } } }
-                ]
-            }
-        }
+  "size": 0,
+  "aggs": {
+    "my_buckets": {
+      "composite": {
+        "sources": [
+          { "tile": { "geotile_grid": { "field": "location", "precision": 8 } } }
+        ]
+      }
     }
+  }
 }
 --------------------------------------------------
 
@@ -400,27 +400,27 @@ precision tiling.
 --------------------------------------------------
 GET /_search
 {
-    "size": 0,
-    "aggs" : {
-        "my_buckets": {
-            "composite" : {
-                "sources" : [
-                    {
-                        "tile": {
-                            "geotile_grid" : {
-                                "field" : "location",
-                                "precision" : 22,
-                                "bounds": {
-                                    "top_left" : "52.4, 4.9",
-                                    "bottom_right" : "52.3, 5.0"
-                                }
-                            }
-                        }
-                    }
-                ]
+  "size": 0,
+  "aggs": {
+    "my_buckets": {
+      "composite": {
+        "sources": [
+          {
+            "tile": {
+              "geotile_grid": {
+                "field": "location",
+                "precision": 22,
+                "bounds": {
+                  "top_left": "52.4, 4.9",
+                  "bottom_right": "52.3, 5.0"
+                }
+              }
             }
-        }
+          }
+        ]
+      }
     }
+  }
 }
 --------------------------------------------------
 
@@ -434,17 +434,17 @@ For example:
 --------------------------------------------------
 GET /_search
 {
-    "size": 0,
-    "aggs" : {
-        "my_buckets": {
-            "composite" : {
-                "sources" : [
-                    { "date": { "date_histogram": { "field": "timestamp", "calendar_interval": "1d" } } },
-                    { "product": { "terms": {"field": "product" } } }
-                ]
-            }
-        }
+  "size": 0,
+  "aggs": {
+    "my_buckets": {
+      "composite": {
+        "sources": [
+          { "date": { "date_histogram": { "field": "timestamp", "calendar_interval": "1d" } } },
+          { "product": { "terms": { "field": "product" } } }
+        ]
+      }
     }
+  }
 }
 --------------------------------------------------
 
@@ -457,18 +457,18 @@ in the composite buckets.
 --------------------------------------------------
 GET /_search
 {
-    "size": 0,
-    "aggs" : {
-        "my_buckets": {
-            "composite" : {
-                "sources" : [
-                    { "shop": { "terms": {"field": "shop" } } },
-                    { "product": { "terms": { "field": "product" } } },
-                    { "date": { "date_histogram": { "field": "timestamp", "calendar_interval": "1d" } } }
-                ]
-            }
-        }
+  "size": 0,
+  "aggs": {
+    "my_buckets": {
+      "composite": {
+        "sources": [
+          { "shop": { "terms": { "field": "shop" } } },
+          { "product": { "terms": { "field": "product" } } },
+          { "date": { "date_histogram": { "field": "timestamp", "calendar_interval": "1d" } } }
+        ]
+      }
     }
+  }
 }
 --------------------------------------------------
 
@@ -487,17 +487,17 @@ For example:
 --------------------------------------------------
 GET /_search
 {
-    "size": 0,
-    "aggs" : {
-        "my_buckets": {
-            "composite" : {
-                "sources" : [
-                    { "date": { "date_histogram": { "field": "timestamp", "calendar_interval": "1d", "order": "desc" } } },
-                    { "product": { "terms": {"field": "product", "order": "asc" } } }
-                ]
-            }
-        }
+  "size": 0,
+  "aggs": {
+    "my_buckets": {
+      "composite": {
+        "sources": [
+          { "date": { "date_histogram": { "field": "timestamp", "calendar_interval": "1d", "order": "desc" } } },
+          { "product": { "terms": { "field": "product", "order": "asc" } } }
+        ]
+      }
     }
+  }
 }
 --------------------------------------------------
 
@@ -514,16 +514,16 @@ It is possible to include them in the response by setting `missing_bucket` to
 --------------------------------------------------
 GET /_search
 {
-    "size": 0,
-    "aggs" : {
-        "my_buckets": {
-            "composite" : {
-                "sources" : [
-                    { "product_name": { "terms" : { "field": "product", "missing_bucket": true } } }
-                ]
-            }
-        }
-     }
+  "size": 0,
+  "aggs": {
+    "my_buckets": {
+      "composite": {
+        "sources": [
+          { "product_name": { "terms": { "field": "product", "missing_bucket": true } } }
+        ]
+      }
+    }
+  }
 }
 --------------------------------------------------
 
@@ -554,18 +554,18 @@ For example:
 --------------------------------------------------
 GET /_search
 {
-    "size": 0,
-    "aggs" : {
-        "my_buckets": {
-            "composite" : {
-                "size": 2,
-                "sources" : [
-                    { "date": { "date_histogram": { "field": "timestamp", "calendar_interval": "1d" } } },
-                    { "product": { "terms": {"field": "product" } } }
-                ]
-            }
-        }
+  "size": 0,
+  "aggs": {
+    "my_buckets": {
+      "composite": {
+        "size": 2,
+        "sources": [
+          { "date": { "date_histogram": { "field": "timestamp", "calendar_interval": "1d" } } },
+          { "product": { "terms": { "field": "product" } } }
+        ]
+      }
     }
+  }
 }
 --------------------------------------------------
 // TEST[s/_search/_search\?filter_path=aggregations/]
@@ -575,31 +575,31 @@ GET /_search
 [source,console-result]
 --------------------------------------------------
 {
-    ...
-    "aggregations": {
-        "my_buckets": {
-            "after_key": {
-                "date": 1494288000000,
-                "product": "mad max"
-            },
-            "buckets": [
-                {
-                    "key": {
-                        "date": 1494201600000,
-                        "product": "rocky"
-                    },
-                    "doc_count": 1
-                },
-                {
-                    "key": {
-                        "date": 1494288000000,
-                        "product": "mad max"
-                    },
-                    "doc_count": 2
-                }
-            ]
+  ...
+  "aggregations": {
+    "my_buckets": {
+      "after_key": {
+        "date": 1494288000000,
+        "product": "mad max"
+      },
+      "buckets": [
+        {
+          "key": {
+            "date": 1494201600000,
+            "product": "rocky"
+          },
+          "doc_count": 1
+        },
+        {
+          "key": {
+            "date": 1494288000000,
+            "product": "mad max"
+          },
+          "doc_count": 2
         }
+      ]
     }
+  }
 }
 --------------------------------------------------
 // TESTRESPONSE[s/\.\.\.//]
@@ -612,19 +612,19 @@ For example, this request uses the `after_key` value provided in the previous re
 --------------------------------------------------
 GET /_search
 {
-    "size": 0,
-    "aggs" : {
-        "my_buckets": {
-            "composite" : {
-                "size": 2,
-                 "sources" : [
-                    { "date": { "date_histogram": { "field": "timestamp", "calendar_interval": "1d", "order": "desc" } } },
-                    { "product": { "terms": {"field": "product", "order": "asc" } } }
-                ],
-                "after": { "date": 1494288000000, "product": "mad max" } <1>
-            }
-        }
+  "size": 0,
+  "aggs": {
+    "my_buckets": {
+      "composite": {
+        "size": 2,
+        "sources": [
+          { "date": { "date_histogram": { "field": "timestamp", "calendar_interval": "1d", "order": "desc" } } },
+          { "product": { "terms": { "field": "product", "order": "asc" } } }
+        ],
+        "after": { "date": 1494288000000, "product": "mad max" } <1>
+      }
     }
+  }
 }
 --------------------------------------------------
 
@@ -644,23 +644,23 @@ For instance the following index sort:
 --------------------------------------------------
 PUT twitter
 {
-    "settings" : {
-        "index" : {
-            "sort.field" : ["username", "timestamp"],   <1>
-            "sort.order" : ["asc", "desc"]              <2>
-        }
-    },
-    "mappings": {
-        "properties": {
-            "username": {
-                "type": "keyword",
-                "doc_values": true
-            },
-            "timestamp": {
-                "type": "date"
-            }
-        }
+  "settings": {
+    "index": {
+      "sort.field": [ "username", "timestamp" ],   <1>
+      "sort.order": [ "asc", "desc" ]              <2>
+    }
+  },
+  "mappings": {
+    "properties": {
+      "username": {
+        "type": "keyword",
+        "doc_values": true
+      },
+      "timestamp": {
+        "type": "date"
+      }
     }
+  }
 }
 --------------------------------------------------
 
@@ -673,16 +673,16 @@ PUT twitter
 --------------------------------------------------
 GET /_search
 {
-    "size": 0,
-    "aggs" : {
-        "my_buckets": {
-            "composite" : {
-                "sources" : [
-                    { "user_name": { "terms" : { "field": "user_name" } } }     <1>
-                ]
-            }
-        }
-     }
+  "size": 0,
+  "aggs": {
+    "my_buckets": {
+      "composite": {
+        "sources": [
+          { "user_name": { "terms": { "field": "user_name" } } }     <1>
+        ]
+      }
+    }
+  }
 }
 --------------------------------------------------
 
@@ -692,17 +692,17 @@ GET /_search
 --------------------------------------------------
 GET /_search
 {
-    "size": 0,
-    "aggs" : {
-        "my_buckets": {
-            "composite" : {
-                "sources" : [
-                    { "user_name": { "terms" : { "field": "user_name" } } }, <1>
-                    { "date": { "date_histogram": { "field": "timestamp", "calendar_interval": "1d", "order": "desc" } } } <2>
-                ]
-            }
-        }
-     }
+  "size": 0,
+  "aggs": {
+    "my_buckets": {
+      "composite": {
+        "sources": [
+          { "user_name": { "terms": { "field": "user_name" } } }, <1>
+          { "date": { "date_histogram": { "field": "timestamp", "calendar_interval": "1d", "order": "desc" } } } <2>
+        ]
+      }
+    }
+  }
 }
 --------------------------------------------------
 
@@ -717,18 +717,18 @@ and it would be costly to compute this number on every page:
 --------------------------------------------------
 GET /_search
 {
-    "size": 0,
-    "track_total_hits": false,
-    "aggs" : {
-        "my_buckets": {
-            "composite" : {
-                "sources" : [
-                    { "user_name": { "terms" : { "field": "user_name" } } },
-                    { "date": { "date_histogram": { "field": "timestamp", "calendar_interval": "1d", "order": "desc" } } }
-                ]
-            }
-        }
-     }
+  "size": 0,
+  "track_total_hits": false,
+  "aggs": {
+    "my_buckets": {
+      "composite": {
+        "sources": [
+          { "user_name": { "terms": { "field": "user_name" } } },
+          { "date": { "date_histogram": { "field": "timestamp", "calendar_interval": "1d", "order": "desc" } } }
+        ]
+      }
+    }
+  }
 }
 --------------------------------------------------
 
@@ -756,22 +756,22 @@ per composite bucket:
 --------------------------------------------------
 GET /_search
 {
-    "size": 0,
-    "aggs" : {
-        "my_buckets": {
-            "composite" : {
-                 "sources" : [
-                    { "date": { "date_histogram": { "field": "timestamp", "calendar_interval": "1d", "order": "desc" } } },
-                    { "product": { "terms": {"field": "product" } } }
-                ]
-            },
-            "aggregations": {
-                "the_avg": {
-                    "avg": { "field": "price" }
-                }
-            }
+  "size": 0,
+  "aggs": {
+    "my_buckets": {
+      "composite": {
+        "sources": [
+          { "date": { "date_histogram": { "field": "timestamp", "calendar_interval": "1d", "order": "desc" } } },
+          { "product": { "terms": { "field": "product" } } }
+        ]
+      },
+      "aggregations": {
+        "the_avg": {
+          "avg": { "field": "price" }
         }
+      }
     }
+  }
 }
 --------------------------------------------------
 // TEST[s/_search/_search\?filter_path=aggregations/]
@@ -781,57 +781,57 @@ GET /_search
 [source,console-result]
 --------------------------------------------------
 {
-    ...
-    "aggregations": {
-        "my_buckets": {
-            "after_key": {
-                "date": 1494201600000,
-                "product": "rocky"
-            },
-            "buckets": [
-                {
-                    "key": {
-                        "date": 1494460800000,
-                        "product": "apocalypse now"
-                    },
-                    "doc_count": 1,
-                    "the_avg": {
-                        "value": 10.0
-                    }
-                },
-                {
-                    "key": {
-                        "date": 1494374400000,
-                        "product": "mad max"
-                    },
-                    "doc_count": 1,
-                    "the_avg": {
-                        "value": 27.0
-                    }
-                },
-                {
-                    "key": {
-                        "date": 1494288000000,
-                        "product" : "mad max"
-                    },
-                    "doc_count": 2,
-                    "the_avg": {
-                        "value": 22.5
-                    }
-                },
-                {
-                    "key": {
-                        "date": 1494201600000,
-                        "product": "rocky"
-                    },
-                    "doc_count": 1,
-                    "the_avg": {
-                        "value": 10.0
-                    }
-                }
-            ]
+  ...
+  "aggregations": {
+    "my_buckets": {
+      "after_key": {
+        "date": 1494201600000,
+        "product": "rocky"
+      },
+      "buckets": [
+        {
+          "key": {
+            "date": 1494460800000,
+            "product": "apocalypse now"
+          },
+          "doc_count": 1,
+          "the_avg": {
+            "value": 10.0
+          }
+        },
+        {
+          "key": {
+            "date": 1494374400000,
+            "product": "mad max"
+          },
+          "doc_count": 1,
+          "the_avg": {
+            "value": 27.0
+          }
+        },
+        {
+          "key": {
+            "date": 1494288000000,
+            "product": "mad max"
+          },
+          "doc_count": 2,
+          "the_avg": {
+            "value": 22.5
+          }
+        },
+        {
+          "key": {
+            "date": 1494201600000,
+            "product": "rocky"
+          },
+          "doc_count": 1,
+          "the_avg": {
+            "value": 10.0
+          }
         }
+      ]
     }
+  }
 }
 --------------------------------------------------
 // TESTRESPONSE[s/\.\.\.//]

+ 101 - 101
docs/reference/aggregations/bucket/datehistogram-aggregation.asciidoc

@@ -119,14 +119,14 @@ As an example, here is an aggregation requesting bucket intervals of a month in
 --------------------------------------------------
 POST /sales/_search?size=0
 {
-    "aggs" : {
-        "sales_over_time" : {
-            "date_histogram" : {
-                "field" : "date",
-                "calendar_interval" : "month"
-            }
-        }
+  "aggs": {
+    "sales_over_time": {
+      "date_histogram": {
+        "field": "date",
+        "calendar_interval": "month"
+      }
     }
+  }
 }
 --------------------------------------------------
 // TEST[setup:sales]
@@ -138,14 +138,14 @@ singular calendar units are supported:
 --------------------------------------------------
 POST /sales/_search?size=0
 {
-    "aggs" : {
-        "sales_over_time" : {
-            "date_histogram" : {
-                "field" : "date",
-                "calendar_interval" : "2d"
-            }
-        }
+  "aggs": {
+    "sales_over_time": {
+      "date_histogram": {
+        "field": "date",
+        "calendar_interval": "2d"
+      }
     }
+  }
 }
 --------------------------------------------------
 // TEST[setup:sales]
@@ -214,14 +214,14 @@ If we try to recreate the "month" `calendar_interval` from earlier, we can appro
 --------------------------------------------------
 POST /sales/_search?size=0
 {
-    "aggs" : {
-        "sales_over_time" : {
-            "date_histogram" : {
-                "field" : "date",
-                "fixed_interval" : "30d"
-            }
-        }
+  "aggs": {
+    "sales_over_time": {
+      "date_histogram": {
+        "field": "date",
+        "fixed_interval": "30d"
+      }
     }
+  }
 }
 --------------------------------------------------
 // TEST[setup:sales]
@@ -232,14 +232,14 @@ But if we try to use a calendar unit that is not supported, such as weeks, we'll
 --------------------------------------------------
 POST /sales/_search?size=0
 {
-    "aggs" : {
-        "sales_over_time" : {
-            "date_histogram" : {
-                "field" : "date",
-                "fixed_interval" : "2w"
-            }
-        }
+  "aggs": {
+    "sales_over_time": {
+      "date_histogram": {
+        "field": "date",
+        "fixed_interval": "2w"
+      }
     }
+  }
 }
 --------------------------------------------------
 // TEST[setup:sales]
@@ -303,15 +303,15 @@ TIP: If you don't specify `format`, the first date
 --------------------------------------------------
 POST /sales/_search?size=0
 {
-    "aggs" : {
-        "sales_over_time" : {
-            "date_histogram" : {
-                "field" : "date",
-                "calendar_interval" : "1M",
-                "format" : "yyyy-MM-dd" <1>
-            }
-        }
+  "aggs": {
+    "sales_over_time": {
+      "date_histogram": {
+        "field": "date",
+        "calendar_interval": "1M",
+        "format": "yyyy-MM-dd" <1>
+      }
     }
+  }
 }
 --------------------------------------------------
 // TEST[setup:sales]
@@ -323,28 +323,28 @@ Response:
 [source,console-result]
 --------------------------------------------------
 {
-    ...
-    "aggregations": {
-        "sales_over_time": {
-            "buckets": [
-                {
-                    "key_as_string": "2015-01-01",
-                    "key": 1420070400000,
-                    "doc_count": 3
-                },
-                {
-                    "key_as_string": "2015-02-01",
-                    "key": 1422748800000,
-                    "doc_count": 2
-                },
-                {
-                    "key_as_string": "2015-03-01",
-                    "key": 1425168000000,
-                    "doc_count": 2
-                }
-            ]
+  ...
+  "aggregations": {
+    "sales_over_time": {
+      "buckets": [
+        {
+          "key_as_string": "2015-01-01",
+          "key": 1420070400000,
+          "doc_count": 3
+        },
+        {
+          "key_as_string": "2015-02-01",
+          "key": 1422748800000,
+          "doc_count": 2
+        },
+        {
+          "key_as_string": "2015-03-01",
+          "key": 1425168000000,
+          "doc_count": 2
         }
+      ]
     }
+  }
 }
 --------------------------------------------------
 // TESTRESPONSE[s/\.\.\./"took": $body.took,"timed_out": false,"_shards": $body._shards,"hits": $body.hits,/]
@@ -567,16 +567,16 @@ bucket and returns the ranges as a hash rather than an array:
 --------------------------------------------------
 POST /sales/_search?size=0
 {
-    "aggs" : {
-        "sales_over_time" : {
-            "date_histogram" : {
-                "field" : "date",
-                "calendar_interval" : "1M",
-                "format" : "yyyy-MM-dd",
-                "keyed": true
-            }
-        }
+  "aggs": {
+    "sales_over_time": {
+      "date_histogram": {
+        "field": "date",
+        "calendar_interval": "1M",
+        "format": "yyyy-MM-dd",
+        "keyed": true
+      }
     }
+  }
 }
 --------------------------------------------------
 // TEST[setup:sales]
@@ -586,28 +586,28 @@ Response:
 [source,console-result]
 --------------------------------------------------
 {
-    ...
-    "aggregations": {
-        "sales_over_time": {
-            "buckets": {
-                "2015-01-01": {
-                    "key_as_string": "2015-01-01",
-                    "key": 1420070400000,
-                    "doc_count": 3
-                },
-                "2015-02-01": {
-                    "key_as_string": "2015-02-01",
-                    "key": 1422748800000,
-                    "doc_count": 2
-                },
-                "2015-03-01": {
-                    "key_as_string": "2015-03-01",
-                    "key": 1425168000000,
-                    "doc_count": 2
-                }
-            }
+  ...
+  "aggregations": {
+    "sales_over_time": {
+      "buckets": {
+        "2015-01-01": {
+          "key_as_string": "2015-01-01",
+          "key": 1420070400000,
+          "doc_count": 3
+        },
+        "2015-02-01": {
+          "key_as_string": "2015-02-01",
+          "key": 1422748800000,
+          "doc_count": 2
+        },
+        "2015-03-01": {
+          "key_as_string": "2015-03-01",
+          "key": 1425168000000,
+          "doc_count": 2
         }
+      }
     }
+  }
 }
 --------------------------------------------------
 // TESTRESPONSE[s/\.\.\./"took": $body.took,"timed_out": false,"_shards": $body._shards,"hits": $body.hits,/]
@@ -638,15 +638,15 @@ have a value.
 --------------------------------------------------
 POST /sales/_search?size=0
 {
-    "aggs" : {
-        "sale_date" : {
-             "date_histogram" : {
-                 "field" : "date",
-                 "calendar_interval": "year",
-                 "missing": "2000/01/01" <1>
-             }
-         }
+  "aggs": {
+    "sale_date": {
+      "date_histogram": {
+        "field": "date",
+        "calendar_interval": "year",
+        "missing": "2000/01/01" <1>
+      }
     }
+  }
 }
 --------------------------------------------------
 // TEST[setup:sales]
@@ -671,16 +671,16 @@ returns the day of the week:
 --------------------------------------------------
 POST /sales/_search?size=0
 {
-    "aggs": {
-        "dayOfWeek": {
-            "terms": {
-                "script": {
-                    "lang": "painless",
-                    "source": "doc['date'].value.dayOfWeekEnum.value"
-                }
-            }
+  "aggs": {
+    "dayOfWeek": {
+      "terms": {
+        "script": {
+          "lang": "painless",
+          "source": "doc['date'].value.dayOfWeekEnum.value"
         }
+      }
     }
+  }
 }
 --------------------------------------------------
 // TEST[setup:sales]

+ 86 - 86
docs/reference/aggregations/bucket/daterange-aggregation.asciidoc

@@ -16,18 +16,18 @@ Example:
 --------------------------------------------------
 POST /sales/_search?size=0
 {
-    "aggs": {
-        "range": {
-            "date_range": {
-                "field": "date",
-                "format": "MM-yyyy",
-                "ranges": [
-                    { "to": "now-10M/M" }, <1>
-                    { "from": "now-10M/M" } <2>
-                ]
-            }
-        }
+  "aggs": {
+    "range": {
+      "date_range": {
+        "field": "date",
+        "format": "MM-yyyy",
+        "ranges": [
+          { "to": "now-10M/M" },  <1>
+          { "from": "now-10M/M" } <2>
+        ]
+      }
     }
+  }
 }
 --------------------------------------------------
 // TEST[setup:sales s/now-10M\/M/10-2015/]
@@ -44,25 +44,25 @@ Response:
 [source,console-result]
 --------------------------------------------------
 {
-    ...
-    "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-*"
-                }
-            ]
+  ...
+  "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-*"
         }
+      ]
     }
+  }
 }
 --------------------------------------------------
 // TESTRESPONSE[s/\.\.\./"took": $body.took,"timed_out": false,"_shards": $body._shards,"hits": $body.hits,/]
@@ -298,19 +298,19 @@ bucket and return the ranges as a hash rather than an array:
 --------------------------------------------------
 POST /sales/_search?size=0
 {
-    "aggs": {
-        "range": {
-            "date_range": {
-                "field": "date",
-                "format": "MM-yyy",
-                "ranges": [
-                    { "to": "now-10M/M" },
-                    { "from": "now-10M/M" }
-                ],
-                "keyed": true
-            }
-        }
+  "aggs": {
+    "range": {
+      "date_range": {
+        "field": "date",
+        "format": "MM-yyy",
+        "ranges": [
+          { "to": "now-10M/M" },
+          { "from": "now-10M/M" }
+        ],
+        "keyed": true
+      }
     }
+  }
 }
 --------------------------------------------------
 // TEST[setup:sales s/now-10M\/M/10-2015/]
@@ -320,23 +320,23 @@ Response:
 [source,console-result]
 --------------------------------------------------
 {
-    ...
-    "aggregations": {
-        "range": {
-            "buckets": {
-                "*-10-2015": {
-                    "to": 1.4436576E12,
-                    "to_as_string": "10-2015",
-                    "doc_count": 7
-                },
-                "10-2015-*": {
-                    "from": 1.4436576E12,
-                    "from_as_string": "10-2015",
-                    "doc_count": 0
-                }
-            }
+  ...
+  "aggregations": {
+    "range": {
+      "buckets": {
+        "*-10-2015": {
+          "to": 1.4436576E12,
+          "to_as_string": "10-2015",
+          "doc_count": 7
+        },
+        "10-2015-*": {
+          "from": 1.4436576E12,
+          "from_as_string": "10-2015",
+          "doc_count": 0
         }
+      }
     }
+  }
 }
 --------------------------------------------------
 // TESTRESPONSE[s/\.\.\./"took": $body.took,"timed_out": false,"_shards": $body._shards,"hits": $body.hits,/]
@@ -347,19 +347,19 @@ It is also possible to customize the key for each range:
 --------------------------------------------------
 POST /sales/_search?size=0
 {
-    "aggs": {
-        "range": {
-            "date_range": {
-                "field": "date",
-                "format": "MM-yyy",
-                "ranges": [
-                    { "from": "01-2015",  "to": "03-2015", "key": "quarter_01" },
-                    { "from": "03-2015", "to": "06-2015", "key": "quarter_02" }
-                ],
-                "keyed": true
-            }
-        }
+  "aggs": {
+    "range": {
+      "date_range": {
+        "field": "date",
+        "format": "MM-yyy",
+        "ranges": [
+          { "from": "01-2015", "to": "03-2015", "key": "quarter_01" },
+          { "from": "03-2015", "to": "06-2015", "key": "quarter_02" }
+        ],
+        "keyed": true
+      }
     }
+  }
 }
 --------------------------------------------------
 // TEST[setup:sales]
@@ -369,27 +369,27 @@ Response:
 [source,console-result]
 --------------------------------------------------
 {
-    ...
-    "aggregations": {
-        "range": {
-            "buckets": {
-                "quarter_01": {
-                    "from": 1.4200704E12,
-                    "from_as_string": "01-2015",
-                    "to": 1.425168E12,
-                    "to_as_string": "03-2015",
-                    "doc_count": 5
-                },
-                "quarter_02": {
-                    "from": 1.425168E12,
-                    "from_as_string": "03-2015",
-                    "to": 1.4331168E12,
-                    "to_as_string": "06-2015",
-                    "doc_count": 2
-                }
-            }
+  ...
+  "aggregations": {
+    "range": {
+      "buckets": {
+        "quarter_01": {
+          "from": 1.4200704E12,
+          "from_as_string": "01-2015",
+          "to": 1.425168E12,
+          "to_as_string": "03-2015",
+          "doc_count": 5
+        },
+        "quarter_02": {
+          "from": 1.425168E12,
+          "from_as_string": "03-2015",
+          "to": 1.4331168E12,
+          "to_as_string": "06-2015",
+          "doc_count": 2
         }
+      }
     }
+  }
 }
 --------------------------------------------------
 // TESTRESPONSE[s/\.\.\./"took": $body.took,"timed_out": false,"_shards": $body._shards,"hits": $body.hits,/]

+ 81 - 81
docs/reference/aggregations/bucket/diversified-sampler-aggregation.asciidoc

@@ -30,27 +30,27 @@ forum posts but ignoring the effects of some prolific users with a tendency to m
 --------------------------------------------------
 POST /stackoverflow/_search?size=0
 {
-    "query": {
-        "query_string": {
-            "query": "tags:elasticsearch"
-        }
-    },
-    "aggs": {
-        "my_unbiased_sample": {
-            "diversified_sampler": {
-                "shard_size": 200,
-                "field" : "author"
-            },
-            "aggs": {
-                "keywords": {
-                    "significant_terms": {
-                        "field": "tags",
-                        "exclude": ["elasticsearch"]
-                    }
-                }
-            }
+  "query": {
+    "query_string": {
+      "query": "tags:elasticsearch"
+    }
+  },
+  "aggs": {
+    "my_unbiased_sample": {
+      "diversified_sampler": {
+        "shard_size": 200,
+        "field": "author"
+      },
+      "aggs": {
+        "keywords": {
+          "significant_terms": {
+            "field": "tags",
+            "exclude": [ "elasticsearch" ]
+          }
         }
+      }
     }
+  }
 }
 --------------------------------------------------
 // TEST[setup:stackoverflow]
@@ -60,24 +60,24 @@ Response:
 [source,console-result]
 --------------------------------------------------
 {
-    ...
-    "aggregations": {
-        "my_unbiased_sample": {
-            "doc_count": 151,<1>
-            "keywords": {<2>
-                "doc_count": 151,
-                "bg_count": 650,
-                "buckets": [
-                    {
-                        "key": "kibana",
-                        "doc_count": 150,
-                        "score": 2.213,
-                        "bg_count": 200
-                    }
-                ]
-            }
-        }
+  ...
+  "aggregations": {
+    "my_unbiased_sample": {
+      "doc_count": 151,           <1>
+      "keywords": {               <2>
+        "doc_count": 151,
+        "bg_count": 650,
+        "buckets": [
+          {
+            "key": "kibana",
+            "doc_count": 150,
+            "score": 2.213,
+            "bg_count": 200
+          }
+        ]
+      }
     }
+  }
 }
 --------------------------------------------------
 // TESTRESPONSE[s/\.\.\./"took": $body.took,"timed_out": false,"_shards": $body._shards,"hits": $body.hits,/]
@@ -95,31 +95,31 @@ multiple values in a tags field to ensure we don't have a sample that consists o
 --------------------------------------------------
 POST /stackoverflow/_search?size=0
 {
-    "query": {
-        "query_string": {
-            "query": "tags:kibana"
+  "query": {
+    "query_string": {
+      "query": "tags:kibana"
+    }
+  },
+  "aggs": {
+    "my_unbiased_sample": {
+      "diversified_sampler": {
+        "shard_size": 200,
+        "max_docs_per_value": 3,
+        "script": {
+          "lang": "painless",
+          "source": "doc['tags'].hashCode()"
         }
-    },
-    "aggs": {
-        "my_unbiased_sample": {
-            "diversified_sampler": {
-                "shard_size": 200,
-                "max_docs_per_value" : 3,
-                "script" : {
-                    "lang": "painless",
-                    "source": "doc['tags'].hashCode()"
-                }
-            },
-            "aggs": {
-                "keywords": {
-                    "significant_terms": {
-                        "field": "tags",
-                        "exclude": ["kibana"]
-                    }
-                }
-            }
+      },
+      "aggs": {
+        "keywords": {
+          "significant_terms": {
+            "field": "tags",
+            "exclude": [ "kibana" ]
+          }
         }
+      }
     }
+  }
 }
 --------------------------------------------------
 // TEST[setup:stackoverflow]
@@ -129,30 +129,30 @@ Response:
 [source,console-result]
 --------------------------------------------------
 {
-    ...
-    "aggregations": {
-        "my_unbiased_sample": {
-            "doc_count": 6,
-            "keywords": {
-                "doc_count": 6,
-                "bg_count": 650,
-                "buckets": [
-                    {
-                        "key": "logstash",
-                        "doc_count": 3,
-                        "score": 2.213,
-                        "bg_count": 50
-                    },
-                    {
-                        "key": "elasticsearch",
-                        "doc_count": 3,
-                        "score": 1.34,
-                        "bg_count": 200
-                    }
-                ]
-            }
-        }
+  ...
+  "aggregations": {
+    "my_unbiased_sample": {
+      "doc_count": 6,
+      "keywords": {
+        "doc_count": 6,
+        "bg_count": 650,
+        "buckets": [
+          {
+            "key": "logstash",
+            "doc_count": 3,
+            "score": 2.213,
+            "bg_count": 50
+          },
+          {
+            "key": "elasticsearch",
+            "doc_count": 3,
+            "score": 1.34,
+            "bg_count": 200
+          }
+        ]
+      }
     }
+  }
 }
 --------------------------------------------------
 // TESTRESPONSE[s/\.\.\./"took": $body.took,"timed_out": false,"_shards": $body._shards,"hits": $body.hits,/]

+ 13 - 13
docs/reference/aggregations/bucket/filter-aggregation.asciidoc

@@ -9,14 +9,14 @@ Example:
 --------------------------------------------------
 POST /sales/_search?size=0
 {
-    "aggs" : {
-        "t_shirts" : {
-            "filter" : { "term": { "type": "t-shirt" } },
-            "aggs" : {
-                "avg_price" : { "avg" : { "field" : "price" } }
-            }
-        }
+  "aggs": {
+    "t_shirts": {
+      "filter": { "term": { "type": "t-shirt" } },
+      "aggs": {
+        "avg_price": { "avg": { "field": "price" } }
+      }
     }
+  }
 }
 --------------------------------------------------
 // TEST[setup:sales]
@@ -28,13 +28,13 @@ Response:
 [source,console-result]
 --------------------------------------------------
 {
-    ...
-    "aggregations" : {
-        "t_shirts" : {
-            "doc_count" : 3,
-            "avg_price" : { "value" : 128.33333333333334 }
-        }
+  ...
+  "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,/]

+ 131 - 131
docs/reference/aggregations/bucket/geodistance-aggregation.asciidoc

@@ -7,13 +7,13 @@ A multi-bucket aggregation that works on `geo_point` fields and conceptually wor
 --------------------------------------------------
 PUT /museums
 {
-    "mappings": {
-        "properties": {
-            "location": {
-                "type": "geo_point"
-            }
-        }
+  "mappings": {
+    "properties": {
+      "location": {
+        "type": "geo_point"
+      }
     }
+  }
 }
 
 POST /museums/_bulk?refresh
@@ -32,19 +32,19 @@ POST /museums/_bulk?refresh
 
 POST /museums/_search?size=0
 {
-    "aggs" : {
-        "rings_around_amsterdam" : {
-            "geo_distance" : {
-                "field" : "location",
-                "origin" : "52.3760, 4.894",
-                "ranges" : [
-                    { "to" : 100000 },
-                    { "from" : 100000, "to" : 300000 },
-                    { "from" : 300000 }
-                ]
-            }
-        }
+  "aggs": {
+    "rings_around_amsterdam": {
+      "geo_distance": {
+        "field": "location",
+        "origin": "52.3760, 4.894",
+        "ranges": [
+          { "to": 100000 },
+          { "from": 100000, "to": 300000 },
+          { "from": 300000 }
+        ]
+      }
     }
+  }
 }
 --------------------------------------------------
 
@@ -53,30 +53,30 @@ Response:
 [source,console-result]
 --------------------------------------------------
 {
-    ...
-    "aggregations": {
-        "rings_around_amsterdam" : {
-            "buckets": [
-                {
-                    "key": "*-100000.0",
-                    "from": 0.0,
-                    "to": 100000.0,
-                    "doc_count": 3
-                },
-                {
-                    "key": "100000.0-300000.0",
-                    "from": 100000.0,
-                    "to": 300000.0,
-                    "doc_count": 1
-                },
-                {
-                    "key": "300000.0-*",
-                    "from": 300000.0,
-                    "doc_count": 2
-                }
-            ]
+  ...
+  "aggregations": {
+    "rings_around_amsterdam": {
+      "buckets": [
+        {
+          "key": "*-100000.0",
+          "from": 0.0,
+          "to": 100000.0,
+          "doc_count": 3
+        },
+        {
+          "key": "100000.0-300000.0",
+          "from": 100000.0,
+          "to": 300000.0,
+          "doc_count": 1
+        },
+        {
+          "key": "300000.0-*",
+          "from": 300000.0,
+          "doc_count": 2
         }
+      ]
     }
+  }
 }
 --------------------------------------------------
 // TESTRESPONSE[s/\.\.\./"took": $body.took,"_shards": $body._shards,"hits":$body.hits,"timed_out":false,/]
@@ -93,20 +93,20 @@ By default, the distance unit is `m` (meters) but it can also accept: `mi` (mile
 --------------------------------------------------
 POST /museums/_search?size=0
 {
-    "aggs" : {
-        "rings" : {
-            "geo_distance" : {
-                "field" : "location",
-                "origin" : "52.3760, 4.894",
-                "unit" : "km", <1>
-                "ranges" : [
-                    { "to" : 100 },
-                    { "from" : 100, "to" : 300 },
-                    { "from" : 300 }
-                ]
-            }
-        }
+  "aggs": {
+    "rings": {
+      "geo_distance": {
+        "field": "location",
+        "origin": "52.3760, 4.894",
+        "unit": "km", <1>
+        "ranges": [
+          { "to": 100 },
+          { "from": 100, "to": 300 },
+          { "from": 300 }
+        ]
+      }
     }
+  }
 }
 --------------------------------------------------
 // TEST[continued]
@@ -119,21 +119,21 @@ There are two distance calculation modes: `arc` (the default), and `plane`. The
 --------------------------------------------------
 POST /museums/_search?size=0
 {
-    "aggs" : {
-        "rings" : {
-            "geo_distance" : {
-                "field" : "location",
-                "origin" : "52.3760, 4.894",
-                "unit" : "km",
-                "distance_type" : "plane",
-                "ranges" : [
-                    { "to" : 100 },
-                    { "from" : 100, "to" : 300 },
-                    { "from" : 300 }
-                ]
-            }
-        }
+  "aggs": {
+    "rings": {
+      "geo_distance": {
+        "field": "location",
+        "origin": "52.3760, 4.894",
+        "unit": "km",
+        "distance_type": "plane",
+        "ranges": [
+          { "to": 100 },
+          { "from": 100, "to": 300 },
+          { "from": 300 }
+        ]
+      }
     }
+  }
 }
 --------------------------------------------------
 // TEST[continued]
@@ -146,20 +146,20 @@ Setting the `keyed` flag to `true` will associate a unique string key with each
 --------------------------------------------------
 POST /museums/_search?size=0
 {
-    "aggs" : {
-        "rings_around_amsterdam" : {
-            "geo_distance" : {
-                "field" : "location",
-                "origin" : "52.3760, 4.894",
-                "ranges" : [
-                    { "to" : 100000 },
-                    { "from" : 100000, "to" : 300000 },
-                    { "from" : 300000 }
-                ],
-                "keyed": true
-            }
-        }
+  "aggs": {
+    "rings_around_amsterdam": {
+      "geo_distance": {
+        "field": "location",
+        "origin": "52.3760, 4.894",
+        "ranges": [
+          { "to": 100000 },
+          { "from": 100000, "to": 300000 },
+          { "from": 300000 }
+        ],
+        "keyed": true
+      }
     }
+  }
 }
 --------------------------------------------------
 // TEST[continued]
@@ -169,27 +169,27 @@ Response:
 [source,console-result]
 --------------------------------------------------
 {
-    ...
-    "aggregations": {
-        "rings_around_amsterdam" : {
-            "buckets": {
-                "*-100000.0": {
-                    "from": 0.0,
-                    "to": 100000.0,
-                    "doc_count": 3
-                },
-                "100000.0-300000.0": {
-                    "from": 100000.0,
-                    "to": 300000.0,
-                    "doc_count": 1
-                },
-                "300000.0-*": {
-                    "from": 300000.0,
-                    "doc_count": 2
-                }
-            }
+  ...
+  "aggregations": {
+    "rings_around_amsterdam": {
+      "buckets": {
+        "*-100000.0": {
+          "from": 0.0,
+          "to": 100000.0,
+          "doc_count": 3
+        },
+        "100000.0-300000.0": {
+          "from": 100000.0,
+          "to": 300000.0,
+          "doc_count": 1
+        },
+        "300000.0-*": {
+          "from": 300000.0,
+          "doc_count": 2
         }
+      }
     }
+  }
 }
 --------------------------------------------------
 // TESTRESPONSE[s/\.\.\./"took": $body.took,"_shards": $body._shards,"hits":$body.hits,"timed_out":false,/]
@@ -200,20 +200,20 @@ It is also possible to customize the key for each range:
 --------------------------------------------------
 POST /museums/_search?size=0
 {
-    "aggs" : {
-        "rings_around_amsterdam" : {
-            "geo_distance" : {
-                "field" : "location",
-                "origin" : "52.3760, 4.894",
-                "ranges" : [
-                    { "to" : 100000, "key": "first_ring" },
-                    { "from" : 100000, "to" : 300000, "key": "second_ring" },
-                    { "from" : 300000, "key": "third_ring" }
-                ],
-                "keyed": true
-            }
-        }
+  "aggs": {
+    "rings_around_amsterdam": {
+      "geo_distance": {
+        "field": "location",
+        "origin": "52.3760, 4.894",
+        "ranges": [
+          { "to": 100000, "key": "first_ring" },
+          { "from": 100000, "to": 300000, "key": "second_ring" },
+          { "from": 300000, "key": "third_ring" }
+        ],
+        "keyed": true
+      }
     }
+  }
 }
 --------------------------------------------------
 // TEST[continued]
@@ -223,27 +223,27 @@ Response:
 [source,console-result]
 --------------------------------------------------
 {
-    ...
-    "aggregations": {
-        "rings_around_amsterdam" : {
-            "buckets": {
-                "first_ring": {
-                    "from": 0.0,
-                    "to": 100000.0,
-                    "doc_count": 3
-                },
-                "second_ring": {
-                    "from": 100000.0,
-                    "to": 300000.0,
-                    "doc_count": 1
-                },
-                "third_ring": {
-                    "from": 300000.0,
-                    "doc_count": 2
-                }
-            }
+  ...
+  "aggregations": {
+    "rings_around_amsterdam": {
+      "buckets": {
+        "first_ring": {
+          "from": 0.0,
+          "to": 100000.0,
+          "doc_count": 3
+        },
+        "second_ring": {
+          "from": 100000.0,
+          "to": 300000.0,
+          "doc_count": 1
+        },
+        "third_ring": {
+          "from": 300000.0,
+          "doc_count": 2
         }
+      }
     }
+  }
 }
 --------------------------------------------------
 // TESTRESPONSE[s/\.\.\./"took": $body.took,"_shards": $body._shards,"hits":$body.hits,"timed_out":false,/]

+ 116 - 116
docs/reference/aggregations/bucket/geohashgrid-aggregation.asciidoc

@@ -21,13 +21,13 @@ The specified field must be of type `geo_point` (which can only be set explicitl
 --------------------------------------------------
 PUT /museums
 {
-    "mappings": {
-          "properties": {
-              "location": {
-                  "type": "geo_point"
-              }
-          }
+  "mappings": {
+    "properties": {
+      "location": {
+        "type": "geo_point"
+      }
     }
+  }
 }
 
 POST /museums/_bulk?refresh
@@ -46,14 +46,14 @@ POST /museums/_bulk?refresh
 
 POST /museums/_search?size=0
 {
-    "aggregations" : {
-        "large-grid" : {
-            "geohash_grid" : {
-                "field" : "location",
-                "precision" : 3
-            }
-        }
+  "aggregations": {
+    "large-grid": {
+      "geohash_grid": {
+        "field": "location",
+        "precision": 3
+      }
     }
+  }
 }
 --------------------------------------------------
 
@@ -62,25 +62,25 @@ Response:
 [source,console-result]
 --------------------------------------------------
 {
-    ...
-    "aggregations": {
-        "large-grid": {
-            "buckets": [
-                {
-                    "key": "u17",
-                    "doc_count": 3
-                },
-                {
-                    "key": "u09",
-                    "doc_count": 2
-                },
-                {
-                    "key": "u15",
-                    "doc_count": 1
-                }
-            ]
-        }
-    }
+  ...
+  "aggregations": {
+  "large-grid": {
+    "buckets": [
+      {
+        "key": "u17",
+        "doc_count": 3
+      },
+      {
+        "key": "u09",
+        "doc_count": 2
+      },
+      {
+        "key": "u15",
+        "doc_count": 1
+      }
+    ]
+  }
+}
 }
 --------------------------------------------------
 // TESTRESPONSE[s/\.\.\./"took": $body.took,"_shards": $body._shards,"hits":$body.hits,"timed_out":false,/]
@@ -93,26 +93,26 @@ When requesting detailed buckets (typically for displaying a "zoomed in" map) a
 --------------------------------------------------
 POST /museums/_search?size=0
 {
-    "aggregations" : {
-        "zoomed-in" : {
-            "filter" : {
-                "geo_bounding_box" : {
-                    "location" : {
-                        "top_left" : "52.4, 4.9",
-                        "bottom_right" : "52.3, 5.0"
-                    }
-                }
-            },
-            "aggregations":{
-                "zoom1":{
-                    "geohash_grid" : {
-                        "field": "location",
-                        "precision": 8
-                    }
-                }
-            }
+  "aggregations": {
+    "zoomed-in": {
+      "filter": {
+        "geo_bounding_box": {
+          "location": {
+            "top_left": "52.4, 4.9",
+            "bottom_right": "52.3, 5.0"
+          }
         }
+      },
+      "aggregations": {
+        "zoom1": {
+          "geohash_grid": {
+            "field": "location",
+            "precision": 8
+          }
+        }
+      }
     }
+  }
 }
 --------------------------------------------------
 // TEST[continued]
@@ -124,26 +124,26 @@ first geohash `u17` returned in the previous example, it should be specified as
 --------------------------------------------------
 POST /museums/_search?size=0
 {
-    "aggregations" : {
-        "zoomed-in" : {
-            "filter" : {
-                "geo_bounding_box" : {
-                    "location" : {
-                        "top_left" : "u17",
-                        "bottom_right" : "u17"
-                    }
-                }
-            },
-            "aggregations":{
-                "zoom1":{
-                    "geohash_grid" : {
-                        "field": "location",
-                        "precision": 8
-                    }
-                }
-            }
+  "aggregations": {
+    "zoomed-in": {
+      "filter": {
+        "geo_bounding_box": {
+          "location": {
+            "top_left": "u17",
+            "bottom_right": "u17"
+          }
+        }
+      },
+      "aggregations": {
+        "zoom1": {
+          "geohash_grid": {
+            "field": "location",
+            "precision": 8
+          }
         }
+      }
     }
+  }
 }
 --------------------------------------------------
 // TEST[continued]
@@ -151,28 +151,28 @@ POST /museums/_search?size=0
 [source,console-result]
 --------------------------------------------------
 {
-    ...
-    "aggregations" : {
-        "zoomed-in" : {
-            "doc_count" : 3,
-            "zoom1" : {
-                "buckets" : [
-                    {
-                        "key" : "u173zy3j",
-                        "doc_count" : 1
-                    },
-                    {
-                        "key" : "u173zvfz",
-                        "doc_count" : 1
-                    },
-                    {
-                        "key" : "u173zt90",
-                        "doc_count" : 1
-                    }
-                ]
-            }
-        }
+  ...
+  "aggregations": {
+    "zoomed-in": {
+      "doc_count": 3,
+      "zoom1": {
+        "buckets": [
+          {
+            "key": "u173zy3j",
+            "doc_count": 1
+          },
+          {
+            "key": "u173zvfz",
+            "doc_count": 1
+          },
+          {
+            "key": "u173zt90",
+            "doc_count": 1
+          }
+        ]
+      }
     }
+  }
 }
 --------------------------------------------------
 // TESTRESPONSE[s/\.\.\./"took": $body.took,"_shards": $body._shards,"hits":$body.hits,"timed_out":false,/]
@@ -206,18 +206,18 @@ to any additional `geo_bounding_box` queries defined in the context of the aggre
 --------------------------------------------------
 POST /museums/_search?size=0
 {
-    "aggregations" : {
-        "tiles-in-bounds" : {
-            "geohash_grid" : {
-                "field" : "location",
-                "precision" : 8,
-                "bounds": {
-                  "top_left" : "53.4375, 4.21875",
-                  "bottom_right" : "52.03125, 5.625"
-                }
-            }
+  "aggregations": {
+    "tiles-in-bounds": {
+      "geohash_grid": {
+        "field": "location",
+        "precision": 8,
+        "bounds": {
+          "top_left": "53.4375, 4.21875",
+          "bottom_right": "52.03125, 5.625"
         }
+      }
     }
+  }
 }
 --------------------------------------------------
 // TEST[continued]
@@ -225,25 +225,25 @@ POST /museums/_search?size=0
 [source,console-result]
 --------------------------------------------------
 {
-    ...
-    "aggregations" : {
-        "tiles-in-bounds" : {
-           "buckets" : [
-               {
-                 "key" : "u173zy3j",
-                 "doc_count" : 1
-               },
-               {
-                 "key" : "u173zvfz",
-                 "doc_count" : 1
-               },
-               {
-                 "key" : "u173zt90",
-                 "doc_count" : 1
-               }
-           ]
+  ...
+  "aggregations": {
+    "tiles-in-bounds": {
+      "buckets": [
+        {
+          "key": "u173zy3j",
+          "doc_count": 1
+        },
+        {
+          "key": "u173zvfz",
+          "doc_count": 1
+        },
+        {
+          "key": "u173zt90",
+          "doc_count": 1
         }
+      ]
     }
+  }
 }
 --------------------------------------------------
 // TESTRESPONSE[s/\.\.\./"took": $body.took,"_shards": $body._shards,"hits":$body.hits,"timed_out":false,/]

+ 96 - 96
docs/reference/aggregations/bucket/geotilegrid-aggregation.asciidoc

@@ -34,13 +34,13 @@ fields, in which case all points will be taken into account during aggregation.
 --------------------------------------------------
 PUT /museums
 {
-    "mappings": {
-          "properties": {
-              "location": {
-                  "type": "geo_point"
-              }
-          }
+  "mappings": {
+    "properties": {
+      "location": {
+        "type": "geo_point"
+      }
     }
+  }
 }
 
 POST /museums/_bulk?refresh
@@ -59,14 +59,14 @@ POST /museums/_bulk?refresh
 
 POST /museums/_search?size=0
 {
-    "aggregations" : {
-        "large-grid" : {
-            "geotile_grid" : {
-                "field" : "location",
-                "precision" : 8
-            }
-        }
+  "aggregations": {
+    "large-grid": {
+      "geotile_grid": {
+        "field": "location",
+        "precision": 8
+      }
     }
+  }
 }
 --------------------------------------------------
 
@@ -75,25 +75,25 @@ Response:
 [source,console-result]
 --------------------------------------------------
 {
-    ...
-    "aggregations": {
-        "large-grid": {
-            "buckets": [
-                {
-                  "key" : "8/131/84",
-                  "doc_count" : 3
-                },
-                {
-                  "key" : "8/129/88",
-                  "doc_count" : 2
-                },
-                {
-                  "key" : "8/131/85",
-                  "doc_count" : 1
-                }
-            ]
+  ...
+  "aggregations": {
+    "large-grid": {
+      "buckets": [
+        {
+          "key": "8/131/84",
+          "doc_count": 3
+        },
+        {
+          "key": "8/129/88",
+          "doc_count": 2
+        },
+        {
+          "key": "8/131/85",
+          "doc_count": 1
         }
+      ]
     }
+  }
 }
 --------------------------------------------------
 // TESTRESPONSE[s/\.\.\./"took": $body.took,"_shards": $body._shards,"hits":$body.hits,"timed_out":false,/]
@@ -109,26 +109,26 @@ will be created and returned.
 --------------------------------------------------
 POST /museums/_search?size=0
 {
-    "aggregations" : {
-        "zoomed-in" : {
-            "filter" : {
-                "geo_bounding_box" : {
-                    "location" : {
-                        "top_left" : "52.4, 4.9",
-                        "bottom_right" : "52.3, 5.0"
-                    }
-                }
-            },
-            "aggregations":{
-                "zoom1":{
-                    "geotile_grid" : {
-                        "field": "location",
-                        "precision": 22
-                    }
-                }
-            }
+  "aggregations": {
+    "zoomed-in": {
+      "filter": {
+        "geo_bounding_box": {
+          "location": {
+            "top_left": "52.4, 4.9",
+            "bottom_right": "52.3, 5.0"
+          }
         }
+      },
+      "aggregations": {
+        "zoom1": {
+          "geotile_grid": {
+            "field": "location",
+            "precision": 22
+          }
+        }
+      }
     }
+  }
 }
 --------------------------------------------------
 // TEST[continued]
@@ -136,28 +136,28 @@ POST /museums/_search?size=0
 [source,console-result]
 --------------------------------------------------
 {
-    ...
-    "aggregations" : {
-        "zoomed-in" : {
-            "doc_count" : 3,
-            "zoom1" : {
-                "buckets" : [
-                    {
-                      "key" : "22/2154412/1378379",
-                      "doc_count" : 1
-                    },
-                    {
-                      "key" : "22/2154385/1378332",
-                      "doc_count" : 1
-                    },
-                    {
-                      "key" : "22/2154259/1378425",
-                      "doc_count" : 1
-                    }
-                ]
-            }
-        }
+  ...
+  "aggregations": {
+    "zoomed-in": {
+      "doc_count": 3,
+      "zoom1": {
+        "buckets": [
+          {
+            "key": "22/2154412/1378379",
+            "doc_count": 1
+          },
+          {
+            "key": "22/2154385/1378332",
+            "doc_count": 1
+          },
+          {
+            "key": "22/2154259/1378425",
+            "doc_count": 1
+          }
+        ]
+      }
     }
+  }
 }
 --------------------------------------------------
 // TESTRESPONSE[s/\.\.\./"took": $body.took,"_shards": $body._shards,"hits":$body.hits,"timed_out":false,/]
@@ -177,18 +177,18 @@ to any additional `geo_bounding_box` queries defined in the context of the aggre
 --------------------------------------------------
 POST /museums/_search?size=0
 {
-    "aggregations" : {
-        "tiles-in-bounds" : {
-            "geotile_grid" : {
-                "field" : "location",
-                "precision" : 22,
-                "bounds": {
-                  "top_left" : "52.4, 4.9",
-                  "bottom_right" : "52.3, 5.0"
-                }
-            }
+  "aggregations": {
+    "tiles-in-bounds": {
+      "geotile_grid": {
+        "field": "location",
+        "precision": 22,
+        "bounds": {
+          "top_left": "52.4, 4.9",
+          "bottom_right": "52.3, 5.0"
         }
+      }
     }
+  }
 }
 --------------------------------------------------
 // TEST[continued]
@@ -196,25 +196,25 @@ POST /museums/_search?size=0
 [source,console-result]
 --------------------------------------------------
 {
-    ...
-    "aggregations" : {
-        "tiles-in-bounds" : {
-           "buckets" : [
-               {
-                 "key" : "22/2154412/1378379",
-                 "doc_count" : 1
-               },
-               {
-                 "key" : "22/2154385/1378332",
-                 "doc_count" : 1
-               },
-               {
-                 "key" : "22/2154259/1378425",
-                 "doc_count" : 1
-               }
-           ]
+  ...
+  "aggregations": {
+    "tiles-in-bounds": {
+      "buckets": [
+        {
+          "key": "22/2154412/1378379",
+          "doc_count": 1
+        },
+        {
+          "key": "22/2154385/1378332",
+          "doc_count": 1
+        },
+        {
+          "key": "22/2154259/1378425",
+          "doc_count": 1
         }
+      ]
     }
+  }
 }
 --------------------------------------------------
 // TESTRESPONSE[s/\.\.\./"took": $body.took,"_shards": $body._shards,"hits":$body.hits,"timed_out":false,/]

+ 22 - 22
docs/reference/aggregations/bucket/global-aggregation.asciidoc

@@ -15,18 +15,18 @@ Example:
 --------------------------------------------------
 POST /sales/_search?size=0
 {
-    "query" : {
-        "match" : { "type" : "t-shirt" }
+  "query": {
+    "match": { "type": "t-shirt" }
+  },
+  "aggs": {
+    "all_products": {
+      "global": {}, <1>
+      "aggs": {     <2>
+      "avg_price": { "avg": { "field": "price" } }
+      }
     },
-    "aggs" : {
-        "all_products" : {
-            "global" : {}, <1>
-            "aggs" : { <2>
-                "avg_price" : { "avg" : { "field" : "price" } }
-            }
-        },
-        "t_shirts": { "avg" : { "field" : "price" } }
-    }
+    "t_shirts": { "avg": { "field": "price" } }
+  }
 }
 --------------------------------------------------
 // TEST[setup:sales]
@@ -44,18 +44,18 @@ The response for the above aggregation:
 [source,console-result]
 --------------------------------------------------
 {
-    ...
-    "aggregations" : {
-        "all_products" : {
-            "doc_count" : 7, <1>
-            "avg_price" : {
-                "value" : 140.71428571428572 <2>
-            }
-        },
-        "t_shirts": {
-            "value" : 128.33333333333334 <3>
-        }
+  ...
+  "aggregations": {
+    "all_products": {
+      "doc_count": 7, <1>
+      "avg_price": {
+        "value": 140.71428571428572 <2>
+      }
+    },
+    "t_shirts": {
+      "value": 128.33333333333334 <3>
     }
+  }
 }
 --------------------------------------------------
 // TESTRESPONSE[s/\.\.\./"took": $body.took,"timed_out": false,"_shards": $body._shards,"hits": $body.hits,/]

+ 156 - 156
docs/reference/aggregations/bucket/histogram-aggregation.asciidoc

@@ -28,14 +28,14 @@ The following snippet "buckets" the products based on their `price` by interval
 --------------------------------------------------
 POST /sales/_search?size=0
 {
-    "aggs" : {
-        "prices" : {
-            "histogram" : {
-                "field" : "price",
-                "interval" : 50
-            }
-        }
+  "aggs": {
+    "prices": {
+      "histogram": {
+        "field": "price",
+        "interval": 50
+      }
     }
+  }
 }
 --------------------------------------------------
 // TEST[setup:sales]
@@ -45,33 +45,33 @@ And the following may be the response:
 [source,console-result]
 --------------------------------------------------
 {
-    ...
-    "aggregations": {
-        "prices" : {
-            "buckets": [
-                {
-                    "key": 0.0,
-                    "doc_count": 1
-                },
-                {
-                    "key": 50.0,
-                    "doc_count": 1
-                },
-                {
-                    "key": 100.0,
-                    "doc_count": 0
-                },
-                {
-                    "key": 150.0,
-                    "doc_count": 2
-                },
-                {
-                    "key": 200.0,
-                    "doc_count": 3
-                }
-            ]
+  ...
+  "aggregations": {
+    "prices": {
+      "buckets": [
+        {
+          "key": 0.0,
+          "doc_count": 1
+        },
+        {
+          "key": 50.0,
+          "doc_count": 1
+        },
+        {
+          "key": 100.0,
+          "doc_count": 0
+        },
+        {
+          "key": 150.0,
+          "doc_count": 2
+        },
+        {
+          "key": 200.0,
+          "doc_count": 3
         }
+      ]
     }
+  }
 }
 --------------------------------------------------
 // TESTRESPONSE[s/\.\.\./"took": $body.took,"timed_out": false,"_shards": $body._shards,"hits": $body.hits,/]
@@ -86,15 +86,15 @@ a higher minimum count thanks to the `min_doc_count` setting:
 --------------------------------------------------
 POST /sales/_search?size=0
 {
-    "aggs" : {
-        "prices" : {
-            "histogram" : {
-                "field" : "price",
-                "interval" : 50,
-                "min_doc_count" : 1
-            }
-        }
+  "aggs": {
+    "prices": {
+      "histogram": {
+        "field": "price",
+        "interval": 50,
+        "min_doc_count": 1
+      }
     }
+  }
 }
 --------------------------------------------------
 // TEST[setup:sales]
@@ -104,29 +104,29 @@ Response:
 [source,console-result]
 --------------------------------------------------
 {
-    ...
-    "aggregations": {
-        "prices" : {
-            "buckets": [
-                {
-                    "key": 0.0,
-                    "doc_count": 1
-                },
-                {
-                    "key": 50.0,
-                    "doc_count": 1
-                },
-                {
-                    "key": 150.0,
-                    "doc_count": 2
-                },
-                {
-                    "key": 200.0,
-                    "doc_count": 3
-                }
-            ]
+  ...
+  "aggregations": {
+    "prices": {
+      "buckets": [
+        {
+          "key": 0.0,
+          "doc_count": 1
+        },
+        {
+          "key": 50.0,
+          "doc_count": 1
+        },
+        {
+          "key": 150.0,
+          "doc_count": 2
+        },
+        {
+          "key": 200.0,
+          "doc_count": 3
         }
+      ]
     }
+  }
 }
 --------------------------------------------------
 // TESTRESPONSE[s/\.\.\./"took": $body.took,"timed_out": false,"_shards": $body._shards,"hits": $body.hits,/]
@@ -161,21 +161,21 @@ Example:
 --------------------------------------------------
 POST /sales/_search?size=0
 {
-    "query" : {
-        "constant_score" : { "filter": { "range" : { "price" : { "to" : "500" } } } }
-    },
-    "aggs" : {
-        "prices" : {
-            "histogram" : {
-                "field" : "price",
-                "interval" : 50,
-                "extended_bounds" : {
-                    "min" : 0,
-                    "max" : 500
-                }
-            }
+  "query": {
+    "constant_score": { "filter": { "range": { "price": { "to": "500" } } } }
+  },
+  "aggs": {
+    "prices": {
+      "histogram": {
+        "field": "price",
+        "interval": 50,
+        "extended_bounds": {
+          "min": 0,
+          "max": 500
         }
+      }
     }
+  }
 }
 --------------------------------------------------
 // TEST[setup:sales]
@@ -198,21 +198,21 @@ Example:
 --------------------------------------------------
 POST /sales/_search?size=0
 {
-    "query" : {
-        "constant_score" : { "filter": { "range" : { "price" : { "to" : "500" } } } }
-    },
-    "aggs" : {
-        "prices" : {
-            "histogram" : {
-                "field" : "price",
-                "interval" : 50,
-                "hard_bounds" : {
-                    "min" : 100,
-                    "max" : 200
-                }
-            }
+  "query": {
+    "constant_score": { "filter": { "range": { "price": { "to": "500" } } } }
+  },
+  "aggs": {
+    "prices": {
+      "histogram": {
+        "field": "price",
+        "interval": 50,
+        "hard_bounds": {
+          "min": 100,
+          "max": 200
         }
+      }
     }
+  }
 }
 --------------------------------------------------
 // TEST[setup:sales]
@@ -245,15 +245,15 @@ instead keyed by the buckets keys:
 --------------------------------------------------
 POST /sales/_search?size=0
 {
-    "aggs" : {
-        "prices" : {
-            "histogram" : {
-                "field" : "price",
-                "interval" : 50,
-                "keyed" : true
-            }
-        }
+  "aggs": {
+    "prices": {
+      "histogram": {
+        "field": "price",
+        "interval": 50,
+        "keyed": true
+      }
     }
+  }
 }
 --------------------------------------------------
 // TEST[setup:sales]
@@ -263,33 +263,33 @@ Response:
 [source,console-result]
 --------------------------------------------------
 {
-    ...
-    "aggregations": {
-        "prices": {
-            "buckets": {
-                "0.0": {
-                    "key": 0.0,
-                    "doc_count": 1
-                },
-                "50.0": {
-                    "key": 50.0,
-                    "doc_count": 1
-                },
-                "100.0": {
-                    "key": 100.0,
-                    "doc_count": 0
-                },
-                "150.0": {
-                    "key": 150.0,
-                    "doc_count": 2
-                },
-                "200.0": {
-                    "key": 200.0,
-                    "doc_count": 3
-                }
-            }
+  ...
+  "aggregations": {
+    "prices": {
+      "buckets": {
+        "0.0": {
+          "key": 0.0,
+          "doc_count": 1
+        },
+        "50.0": {
+          "key": 50.0,
+          "doc_count": 1
+        },
+        "100.0": {
+          "key": 100.0,
+          "doc_count": 0
+        },
+        "150.0": {
+          "key": 150.0,
+          "doc_count": 2
+        },
+        "200.0": {
+          "key": 200.0,
+          "doc_count": 3
         }
+      }
     }
+  }
 }
 --------------------------------------------------
 // TESTRESPONSE[s/\.\.\./"took": $body.took,"timed_out": false,"_shards": $body._shards,"hits": $body.hits,/]
@@ -304,15 +304,15 @@ had a value.
 --------------------------------------------------
 POST /sales/_search?size=0
 {
-    "aggs" : {
-        "quantity" : {
-             "histogram" : {
-                 "field" : "quantity",
-                 "interval": 10,
-                 "missing": 0 <1>
-             }
-         }
+  "aggs": {
+    "quantity": {
+      "histogram": {
+        "field": "quantity",
+        "interval": 10,
+        "missing": 0 <1>
+      }
     }
+  }
 }
 --------------------------------------------------
 // TEST[setup:sales]
@@ -349,14 +349,14 @@ PUT metrics_index/_doc/2
 
 POST /metrics_index/_search?size=0
 {
-    "aggs" : {
-        "latency_buckets" : {
-            "histogram" : {
-                "field" : "latency_histo",
-                "interval" : 5
-            }
-        }
+  "aggs": {
+    "latency_buckets": {
+      "histogram": {
+        "field": "latency_histo",
+        "interval": 5
+      }
     }
+  }
 }
 --------------------------------------------------
 
@@ -367,29 +367,29 @@ return the following output:
 [source,console-result]
 --------------------------------------------------
 {
-    ...
-    "aggregations": {
-        "prices" : {
-            "buckets": [
-                {
-                    "key": 0.0,
-                    "doc_count": 18
-                },
-                {
-                    "key": 5.0,
-                    "doc_count": 48
-                },
-                {
-                    "key": 10.0,
-                    "doc_count": 25
-                },
-                {
-                    "key": 15.0,
-                    "doc_count": 6
-                }
-            ]
+  ...
+  "aggregations": {
+    "prices": {
+      "buckets": [
+        {
+          "key": 0.0,
+          "doc_count": 18
+        },
+        {
+          "key": 5.0,
+          "doc_count": 48
+        },
+        {
+          "key": 10.0,
+          "doc_count": 25
+        },
+        {
+          "key": 15.0,
+          "doc_count": 6
         }
+      ]
     }
+  }
 }
 --------------------------------------------------
 // TESTRESPONSE[skip:test not setup]

+ 108 - 108
docs/reference/aggregations/bucket/iprange-aggregation.asciidoc

@@ -9,18 +9,18 @@ Example:
 --------------------------------------------------
 GET /ip_addresses/_search
 {
-    "size": 10,
-    "aggs" : {
-        "ip_ranges" : {
-            "ip_range" : {
-                "field" : "ip",
-                "ranges" : [
-                    { "to" : "10.0.0.5" },
-                    { "from" : "10.0.0.5" }
-                ]
-            }
-        }
+  "size": 10,
+  "aggs": {
+    "ip_ranges": {
+      "ip_range": {
+        "field": "ip",
+        "ranges": [
+          { "to": "10.0.0.5" },
+          { "from": "10.0.0.5" }
+        ]
+      }
     }
+  }
 }
 --------------------------------------------------
 // TEST[setup:iprange]
@@ -30,24 +30,24 @@ Response:
 [source,console-result]
 --------------------------------------------------
 {
-    ...
-
-    "aggregations": {
-        "ip_ranges": {
-            "buckets" : [
-                {
-                    "key": "*-10.0.0.5",
-                    "to": "10.0.0.5",
-                    "doc_count": 10
-                },
-                {
-                    "key": "10.0.0.5-*",
-                    "from": "10.0.0.5",
-                    "doc_count": 260
-                }
-            ]
+  ...
+
+  "aggregations": {
+    "ip_ranges": {
+      "buckets": [
+        {
+          "key": "*-10.0.0.5",
+          "to": "10.0.0.5",
+          "doc_count": 10
+        },
+        {
+          "key": "10.0.0.5-*",
+          "from": "10.0.0.5",
+          "doc_count": 260
         }
+      ]
     }
+  }
 }
 --------------------------------------------------
 // TESTRESPONSE[s/\.\.\./"took": $body.took,"timed_out": false,"_shards": $body._shards,"hits": $body.hits,/]
@@ -58,18 +58,18 @@ IP ranges can also be defined as CIDR masks:
 --------------------------------------------------
 GET /ip_addresses/_search
 {
-    "size": 0,
-    "aggs" : {
-        "ip_ranges" : {
-            "ip_range" : {
-                "field" : "ip",
-                "ranges" : [
-                    { "mask" : "10.0.0.0/25" },
-                    { "mask" : "10.0.0.127/25" }
-                ]
-            }
-        }
+  "size": 0,
+  "aggs": {
+    "ip_ranges": {
+      "ip_range": {
+        "field": "ip",
+        "ranges": [
+          { "mask": "10.0.0.0/25" },
+          { "mask": "10.0.0.127/25" }
+        ]
+      }
     }
+  }
 }
 --------------------------------------------------
 // TEST[setup:iprange]
@@ -79,26 +79,26 @@ Response:
 [source,console-result]
 --------------------------------------------------
 {
-    ...
-
-    "aggregations": {
-        "ip_ranges": {
-            "buckets": [
-                {
-                    "key": "10.0.0.0/25",
-                    "from": "10.0.0.0",
-                    "to": "10.0.0.128",
-                    "doc_count": 128
-                },
-                {
-                    "key": "10.0.0.127/25",
-                    "from": "10.0.0.0",
-                    "to": "10.0.0.128",
-                    "doc_count": 128
-                }
-            ]
+  ...
+
+  "aggregations": {
+    "ip_ranges": {
+      "buckets": [
+        {
+          "key": "10.0.0.0/25",
+          "from": "10.0.0.0",
+          "to": "10.0.0.128",
+          "doc_count": 128
+        },
+        {
+          "key": "10.0.0.127/25",
+          "from": "10.0.0.0",
+          "to": "10.0.0.128",
+          "doc_count": 128
         }
+      ]
     }
+  }
 }
 --------------------------------------------------
 // TESTRESPONSE[s/\.\.\./"took": $body.took,"timed_out": false,"_shards": $body._shards,"hits": $body.hits,/]
@@ -111,19 +111,19 @@ Setting the `keyed` flag to `true` will associate a unique string key with each
 --------------------------------------------------
 GET /ip_addresses/_search
 {
-    "size": 0,
-    "aggs": {
-        "ip_ranges": {
-            "ip_range": {
-                "field": "ip",
-                "ranges": [
-                    { "to" : "10.0.0.5" },
-                    { "from" : "10.0.0.5" }
-                ],
-                "keyed": true
-            }
-        }
+  "size": 0,
+  "aggs": {
+    "ip_ranges": {
+      "ip_range": {
+        "field": "ip",
+        "ranges": [
+          { "to": "10.0.0.5" },
+          { "from": "10.0.0.5" }
+        ],
+        "keyed": true
+      }
     }
+  }
 }
 --------------------------------------------------
 // TEST[setup:iprange]
@@ -133,22 +133,22 @@ Response:
 [source,console-result]
 --------------------------------------------------
 {
-    ...
-
-    "aggregations": {
-        "ip_ranges": {
-            "buckets": {
-                "*-10.0.0.5": {
-                    "to": "10.0.0.5",
-                    "doc_count": 10
-                },
-                "10.0.0.5-*": {
-                    "from": "10.0.0.5",
-                    "doc_count": 260
-                }
-            }
+  ...
+
+  "aggregations": {
+    "ip_ranges": {
+      "buckets": {
+        "*-10.0.0.5": {
+          "to": "10.0.0.5",
+          "doc_count": 10
+        },
+        "10.0.0.5-*": {
+          "from": "10.0.0.5",
+          "doc_count": 260
         }
+      }
     }
+  }
 }
 --------------------------------------------------
 // TESTRESPONSE[s/\.\.\./"took": $body.took,"timed_out": false,"_shards": $body._shards,"hits": $body.hits,/]
@@ -159,19 +159,19 @@ It is also possible to customize the key for each range:
 --------------------------------------------------
 GET /ip_addresses/_search
 {
-    "size": 0,
-    "aggs": {
-        "ip_ranges": {
-            "ip_range": {
-                "field": "ip",
-                "ranges": [
-                    { "key": "infinity", "to" : "10.0.0.5" },
-                    { "key": "and-beyond", "from" : "10.0.0.5" }
-                ],
-                "keyed": true
-            }
-        }
+  "size": 0,
+  "aggs": {
+    "ip_ranges": {
+      "ip_range": {
+        "field": "ip",
+        "ranges": [
+          { "key": "infinity", "to": "10.0.0.5" },
+          { "key": "and-beyond", "from": "10.0.0.5" }
+        ],
+        "keyed": true
+      }
     }
+  }
 }
 --------------------------------------------------
 // TEST[setup:iprange]
@@ -181,22 +181,22 @@ Response:
 [source,console-result]
 --------------------------------------------------
 {
-    ...
-
-    "aggregations": {
-        "ip_ranges": {
-            "buckets": {
-                "infinity": {
-                    "to": "10.0.0.5",
-                    "doc_count": 10
-                },
-                "and-beyond": {
-                    "from": "10.0.0.5",
-                    "doc_count": 260
-                }
-            }
+  ...
+
+  "aggregations": {
+    "ip_ranges": {
+      "buckets": {
+        "infinity": {
+          "to": "10.0.0.5",
+          "doc_count": 10
+        },
+        "and-beyond": {
+          "from": "10.0.0.5",
+          "doc_count": 260
         }
+      }
     }
+  }
 }
 --------------------------------------------------
 // TESTRESPONSE[s/\.\.\./"took": $body.took,"timed_out": false,"_shards": $body._shards,"hits": $body.hits,/]

+ 9 - 9
docs/reference/aggregations/bucket/missing-aggregation.asciidoc

@@ -9,11 +9,11 @@ Example:
 --------------------------------------------------
 POST /sales/_search?size=0
 {
-    "aggs" : {
-        "products_without_a_price" : {
-            "missing" : { "field" : "price" }
-        }
+  "aggs": {
+    "products_without_a_price": {
+      "missing": { "field": "price" }
     }
+  }
 }
 --------------------------------------------------
 // TEST[setup:sales]
@@ -25,12 +25,12 @@ Response:
 [source,console-result]
 --------------------------------------------------
 {
-    ...
-    "aggregations" : {
-        "products_without_a_price" : {
-            "doc_count" : 00
-        }
+  ...
+  "aggregations": {
+    "products_without_a_price": {
+      "doc_count": 00
     }
+  }
 }
 --------------------------------------------------
 // TESTRESPONSE[s/\.\.\./"took": $body.took,"timed_out": false,"_shards": $body._shards,"hits": $body.hits,/]

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

@@ -10,17 +10,17 @@ price for the product. The mapping could look like:
 --------------------------------------------------
 PUT /products
 {
-    "mappings": {
-        "properties" : {
-            "resellers" : { <1>
-                "type" : "nested",
-                "properties" : {
-                    "reseller" : { "type" : "text" },
-                    "price" : { "type" : "double" }
-                }
-            }
+  "mappings": {
+    "properties": {
+      "resellers": { <1>
+        "type": "nested",
+        "properties": {
+          "reseller": { "type": "text" },
+          "price": { "type": "double" }
         }
+      }
     }
+  }
 }
 --------------------------------------------------
 <1> `resellers` is an array that holds nested documents.
@@ -55,19 +55,19 @@ The following request returns the minimum price a product can be purchased for:
 --------------------------------------------------
 GET /products/_search
 {
-    "query" : {
-        "match" : { "name" : "led tv" }
-    },
-    "aggs" : {
-        "resellers" : {
-            "nested" : {
-                "path" : "resellers"
-            },
-            "aggs" : {
-                "min_price" : { "min" : { "field" : "resellers.price" } }
-            }
-        }
+  "query": {
+    "match": { "name": "led tv" }
+  },
+  "aggs": {
+    "resellers": {
+      "nested": {
+        "path": "resellers"
+      },
+      "aggs": {
+        "min_price": { "min": { "field": "resellers.price" } }
+      }
     }
+  }
 }
 --------------------------------------------------
 // TEST[s/GET \/products\/_search/GET \/products\/_search\?filter_path=aggregations/]

+ 169 - 169
docs/reference/aggregations/bucket/range-aggregation.asciidoc

@@ -10,18 +10,18 @@ Example:
 --------------------------------------------------
 GET /_search
 {
-    "aggs" : {
-        "price_ranges" : {
-            "range" : {
-                "field" : "price",
-                "ranges" : [
-                    { "to" : 100.0 },
-                    { "from" : 100.0, "to" : 200.0 },
-                    { "from" : 200.0 }
-                ]
-            }
-        }
+  "aggs": {
+    "price_ranges": {
+      "range": {
+        "field": "price",
+        "ranges": [
+          { "to": 100.0 },
+          { "from": 100.0, "to": 200.0 },
+          { "from": 200.0 }
+        ]
+      }
     }
+  }
 }
 --------------------------------------------------
 // TEST[setup:sales]
@@ -32,29 +32,29 @@ Response:
 [source,console-result]
 --------------------------------------------------
 {
-    ...
-    "aggregations": {
-        "price_ranges" : {
-            "buckets": [
-                {
-                    "key": "*-100.0",
-                    "to": 100.0,
-                    "doc_count": 2
-                },
-                {
-                    "key": "100.0-200.0",
-                    "from": 100.0,
-                    "to": 200.0,
-                    "doc_count": 2
-                },
-                {
-                    "key": "200.0-*",
-                    "from": 200.0,
-                    "doc_count": 3
-                }
-            ]
+  ...
+  "aggregations": {
+    "price_ranges": {
+      "buckets": [
+        {
+          "key": "*-100.0",
+          "to": 100.0,
+          "doc_count": 2
+        },
+        {
+          "key": "100.0-200.0",
+          "from": 100.0,
+          "to": 200.0,
+          "doc_count": 2
+        },
+        {
+          "key": "200.0-*",
+          "from": 200.0,
+          "doc_count": 3
         }
+      ]
     }
+  }
 }
 --------------------------------------------------
 // TESTRESPONSE[s/\.\.\.//]
@@ -67,19 +67,19 @@ Setting the `keyed` flag to `true` will associate a unique string key with each
 --------------------------------------------------
 GET /_search
 {
-    "aggs" : {
-        "price_ranges" : {
-            "range" : {
-                "field" : "price",
-                "keyed" : true,
-                "ranges" : [
-                    { "to" : 100 },
-                    { "from" : 100, "to" : 200 },
-                    { "from" : 200 }
-                ]
-            }
-        }
+  "aggs": {
+    "price_ranges": {
+      "range": {
+        "field": "price",
+        "keyed": true,
+        "ranges": [
+          { "to": 100 },
+          { "from": 100, "to": 200 },
+          { "from": 200 }
+        ]
+      }
     }
+  }
 }
 --------------------------------------------------
 // TEST[setup:sales]
@@ -90,26 +90,26 @@ Response:
 [source,console-result]
 --------------------------------------------------
 {
-    ...
-    "aggregations": {
-        "price_ranges" : {
-            "buckets": {
-                "*-100.0": {
-                    "to": 100.0,
-                    "doc_count": 2
-                },
-                "100.0-200.0": {
-                    "from": 100.0,
-                    "to": 200.0,
-                    "doc_count": 2
-                },
-                "200.0-*": {
-                    "from": 200.0,
-                    "doc_count": 3
-                }
-            }
+  ...
+  "aggregations": {
+    "price_ranges": {
+      "buckets": {
+        "*-100.0": {
+          "to": 100.0,
+          "doc_count": 2
+        },
+        "100.0-200.0": {
+          "from": 100.0,
+          "to": 200.0,
+          "doc_count": 2
+        },
+        "200.0-*": {
+          "from": 200.0,
+          "doc_count": 3
         }
+      }
     }
+  }
 }
 --------------------------------------------------
 // TESTRESPONSE[s/\.\.\.//]
@@ -120,19 +120,19 @@ It is also possible to customize the key for each range:
 --------------------------------------------------
 GET /_search
 {
-    "aggs" : {
-        "price_ranges" : {
-            "range" : {
-                "field" : "price",
-                "keyed" : true,
-                "ranges" : [
-                    { "key" : "cheap", "to" : 100 },
-                    { "key" : "average", "from" : 100, "to" : 200 },
-                    { "key" : "expensive", "from" : 200 }
-                ]
-            }
-        }
+  "aggs": {
+    "price_ranges": {
+      "range": {
+        "field": "price",
+        "keyed": true,
+        "ranges": [
+          { "key": "cheap", "to": 100 },
+          { "key": "average", "from": 100, "to": 200 },
+          { "key": "expensive", "from": 200 }
+        ]
+      }
     }
+  }
 }
 --------------------------------------------------
 // TEST[setup:sales]
@@ -143,26 +143,26 @@ Response:
 [source,console-result]
 --------------------------------------------------
 {
-    ...
-    "aggregations": {
-        "price_ranges" : {
-            "buckets": {
-                "cheap": {
-                    "to": 100.0,
-                    "doc_count": 2
-                },
-                "average": {
-                    "from": 100.0,
-                    "to": 200.0,
-                    "doc_count": 2
-                },
-                "expensive": {
-                    "from": 200.0,
-                    "doc_count": 3
-                }
-            }
+  ...
+  "aggregations": {
+    "price_ranges": {
+      "buckets": {
+        "cheap": {
+          "to": 100.0,
+          "doc_count": 2
+        },
+        "average": {
+          "from": 100.0,
+          "to": 200.0,
+          "doc_count": 2
+        },
+        "expensive": {
+          "from": 200.0,
+          "doc_count": 3
         }
+      }
     }
+  }
 }
 --------------------------------------------------
 // TESTRESPONSE[s/\.\.\.//]
@@ -178,21 +178,21 @@ The following example shows how to use an `inline` script with the `painless` sc
 --------------------------------------------------
 GET /_search
 {
-    "aggs" : {
-        "price_ranges" : {
-            "range" : {
-                "script" : {
-                    "lang": "painless",
-                    "source": "doc['price'].value"
-                },
-                "ranges" : [
-                    { "to" : 100 },
-                    { "from" : 100, "to" : 200 },
-                    { "from" : 200 }
-                ]
-            }
-        }
+  "aggs": {
+    "price_ranges": {
+      "range": {
+        "script": {
+          "lang": "painless",
+          "source": "doc['price'].value"
+        },
+        "ranges": [
+          { "to": 100 },
+          { "from": 100, "to": 200 },
+          { "from": 200 }
+        ]
+      }
     }
+  }
 }
 --------------------------------------------------
 
@@ -216,23 +216,23 @@ And this new stored script can be used in the range aggregation like this:
 --------------------------------------------------
 GET /_search
 {
-    "aggs" : {
-        "price_ranges" : {
-            "range" : {
-                "script" : {
-                    "id": "convert_currency", <1>
-                    "params": { <2>
-                        "field": "price",
-                        "conversion_rate": 0.835526591
-                    }
-                },
-                "ranges" : [
-                    { "from" : 0, "to" : 100 },
-                    { "from" : 100 }
-                ]
-            }
-        }
+  "aggs": {
+    "price_ranges": {
+      "range": {
+        "script": {
+          "id": "convert_currency",       <1>
+          "params": {                     <2>
+            "field": "price",
+            "conversion_rate": 0.835526591
+          }
+        },
+        "ranges": [
+          { "from": 0, "to": 100 },
+          { "from": 100 }
+        ]
+      }
     }
+  }
 }
 --------------------------------------------------
 // TEST[s/GET \/_search/GET \/_search\?filter_path=aggregations/]
@@ -245,23 +245,23 @@ GET /_search
 [source,console-result]
 --------------------------------------------------
 {
-    "aggregations": {
-        "price_ranges" : {
-            "buckets": [
-                {
-                  "key" : "0.0-100.0",
-                  "from" : 0.0,
-                  "to" : 100.0,
-                  "doc_count" : 2
-                },
-                {
-                  "key" : "100.0-*",
-                  "from" : 100.0,
-                  "doc_count" : 5
-                }
-            ]
+  "aggregations": {
+    "price_ranges": {
+      "buckets": [
+        {
+          "key": "0.0-100.0",
+          "from": 0.0,
+          "to": 100.0,
+          "doc_count": 2
+        },
+        {
+          "key": "100.0-*",
+          "from": 100.0,
+          "doc_count": 5
         }
+      ]
     }
+  }
 }
 --------------------------------------------------
 
@@ -275,24 +275,24 @@ Lets say the product prices are in USD but we would like to get the price ranges
 --------------------------------------------------
 GET /sales/_search
 {
-    "aggs" : {
-        "price_ranges" : {
-            "range" : {
-                "field" : "price",
-                "script" : {
-                    "source": "_value * params.conversion_rate",
-                    "params" : {
-                        "conversion_rate" : 0.8
-                    }
-                },
-                "ranges" : [
-                    { "to" : 35 },
-                    { "from" : 35, "to" : 70 },
-                    { "from" : 70 }
-                ]
-            }
-        }
+  "aggs": {
+    "price_ranges": {
+      "range": {
+        "field": "price",
+        "script": {
+          "source": "_value * params.conversion_rate",
+          "params": {
+            "conversion_rate": 0.8
+          }
+        },
+        "ranges": [
+          { "to": 35 },
+          { "from": 35, "to": 70 },
+          { "from": 70 }
+        ]
+      }
     }
+  }
 }
 --------------------------------------------------
 // TEST[setup:sales]
@@ -305,23 +305,23 @@ The following example, not only "bucket" the documents to the different buckets
 --------------------------------------------------
 GET /_search
 {
-    "aggs" : {
-        "price_ranges" : {
-            "range" : {
-                "field" : "price",
-                "ranges" : [
-                    { "to" : 100 },
-                    { "from" : 100, "to" : 200 },
-                    { "from" : 200 }
-                ]
-            },
-            "aggs" : {
-                "price_stats" : {
-                    "stats" : { "field" : "price" }
-                }
-            }
+  "aggs": {
+    "price_ranges": {
+      "range": {
+        "field": "price",
+        "ranges": [
+          { "to": 100 },
+          { "from": 100, "to": 200 },
+          { "from": 200 }
+        ]
+      },
+      "aggs": {
+        "price_stats": {
+          "stats": { "field": "price" }
         }
+      }
     }
+  }
 }
 --------------------------------------------------
 // TEST[setup:sales]

+ 22 - 22
docs/reference/aggregations/bucket/range-field-note.asciidoc

@@ -49,14 +49,14 @@ document will land in multiple buckets.
 --------------------------------------------------
 POST /range_index/_search?size=0
 {
-    "aggs" : {
-        "range_histo" : {
-            "histogram" : {
-                "field" : "expected_attendees",
-                "interval" : 5
-            }
-        }
+  "aggs": {
+    "range_histo": {
+      "histogram": {
+        "field": "expected_attendees",
+        "interval": 5
+      }
     }
+  }
 }
 --------------------------------------------------
 
@@ -105,23 +105,23 @@ Consider the following aggregation on the above document:
 --------------------------------------------------
 POST /range_index/_search?size=0
 {
-    "query": {
-      "range": {
-        "time_frame": {
-          "gte": "2019-11-01",
-          "format": "yyyy-MM-dd"
-        }
+  "query": {
+    "range": {
+      "time_frame": {
+        "gte": "2019-11-01",
+        "format": "yyyy-MM-dd"
       }
-    }, 
-    "aggs" : {
-        "november_data" : {
-            "date_histogram" : {
-                "field" : "time_frame",
-                "calendar_interval" : "day",
-                "format": "yyyy-MM-dd"
-              }
-        }
     }
+  },
+  "aggs": {
+    "november_data": {
+      "date_histogram": {
+        "field": "time_frame",
+        "calendar_interval": "day",
+        "format": "yyyy-MM-dd"
+      }
+    }
+  }
 }
 --------------------------------------------------
 

+ 71 - 71
docs/reference/aggregations/bucket/rare-terms-aggregation.asciidoc

@@ -13,16 +13,16 @@ aggregation
 --------------------------------------------------
 PUT /products
 {
-    "mappings": {
-        "properties": {
-            "genre": {
-                "type": "keyword"
-            },
-            "product": {
-                "type": "keyword"
-            }
-        }
+  "mappings": {
+    "properties": {
+      "genre": {
+        "type": "keyword"
+      },
+      "product": {
+        "type": "keyword"
+      }
     }
+  }
 }
 
 POST /products/_bulk?refresh
@@ -62,10 +62,10 @@ A `rare_terms` aggregation looks like this in isolation:
 [source,js]
 --------------------------------------------------
 {
-    "rare_terms": {
-        "field": "the_field",
-        "max_doc_count": 1
-    }
+  "rare_terms": {
+    "field": "the_field",
+    "max_doc_count": 1
+  }
 }
 --------------------------------------------------
 // NOTCONSOLE
@@ -89,13 +89,13 @@ Example:
 --------------------------------------------------
 GET /_search
 {
-    "aggs" : {
-        "genres" : {
-            "rare_terms" : {
-                "field" : "genre"
-            }
-        }
+  "aggs": {
+    "genres": {
+      "rare_terms": {
+        "field": "genre"
+      }
     }
+  }
 }
 --------------------------------------------------
 // TEST[s/_search/_search\?filter_path=aggregations/]
@@ -105,17 +105,17 @@ Response:
 [source,console-result]
 --------------------------------------------------
 {
-    ...
-    "aggregations" : {
-        "genres" : {
-            "buckets" : [
-                {
-                    "key" : "swing",
-                    "doc_count" : 1
-                }
-            ]
+  ...
+  "aggregations": {
+    "genres": {
+      "buckets": [
+        {
+          "key": "swing",
+          "doc_count": 1
         }
+      ]
     }
+  }
 }
 --------------------------------------------------
 // TESTRESPONSE[s/\.\.\.//]
@@ -127,14 +127,14 @@ one document.  If we increase the `max_doc_count` to `2`, we'll see some more bu
 --------------------------------------------------
 GET /_search
 {
-    "aggs" : {
-        "genres" : {
-            "rare_terms" : {
-                "field" : "genre",
-                "max_doc_count": 2
-            }
-        }
+  "aggs": {
+    "genres": {
+      "rare_terms": {
+        "field": "genre",
+        "max_doc_count": 2
+      }
     }
+  }
 }
 --------------------------------------------------
 // TEST[s/_search/_search\?filter_path=aggregations/]
@@ -144,21 +144,21 @@ This now shows the "jazz" term which has a `doc_count` of 2":
 [source,console-result]
 --------------------------------------------------
 {
-    ...
-    "aggregations" : {
-        "genres" : {
-            "buckets" : [
-                {
-                    "key" : "swing",
-                    "doc_count" : 1
-                },
-                {
-                    "key" : "jazz",
-                    "doc_count" : 2
-                }
-            ]
+  ...
+  "aggregations": {
+    "genres": {
+      "buckets": [
+        {
+          "key": "swing",
+          "doc_count": 1
+        },
+        {
+          "key": "jazz",
+          "doc_count": 2
         }
+      ]
     }
+  }
 }
 --------------------------------------------------
 // TESTRESPONSE[s/\.\.\.//]
@@ -277,15 +277,15 @@ It is possible to filter the values for which buckets will be created. This can
 --------------------------------------------------
 GET /_search
 {
-    "aggs" : {
-        "genres" : {
-            "rare_terms" : {
-                "field" : "genre",
-                "include" : "swi*",
-                "exclude" : "electro*"
-            }
-        }
+  "aggs": {
+    "genres": {
+      "rare_terms": {
+        "field": "genre",
+        "include": "swi*",
+        "exclude": "electro*"
+      }
     }
+  }
 }
 --------------------------------------------------
 
@@ -305,15 +305,15 @@ strings that represent the terms as they are found in the index:
 --------------------------------------------------
 GET /_search
 {
-    "aggs" : {
-        "genres" : {
-             "rare_terms" : {
-                 "field" : "genre",
-                 "include" : ["swing", "rock"],
-                 "exclude" : ["jazz"]
-             }
-         }
+  "aggs": {
+    "genres": {
+      "rare_terms": {
+        "field": "genre",
+        "include": [ "swing", "rock" ],
+        "exclude": [ "jazz" ]
+      }
     }
+  }
 }
 --------------------------------------------------
 
@@ -328,14 +328,14 @@ had a value.
 --------------------------------------------------
 GET /_search
 {
-    "aggs" : {
-        "genres" : {
-             "rare_terms" : {
-                 "field" : "genre",
-                 "missing": "N/A" <1>
-             }
-         }
+  "aggs": {
+    "genres": {
+      "rare_terms": {
+        "field": "genre",
+        "missing": "N/A" <1>
+      }
     }
+  }
 }
 --------------------------------------------------
 

+ 11 - 11
docs/reference/aggregations/bucket/reverse-nested-aggregation.asciidoc

@@ -19,18 +19,18 @@ the issue documents as nested documents. The mapping could look like:
 --------------------------------------------------
 PUT /issues
 {
-    "mappings": {
-         "properties" : {
-             "tags" : { "type" : "keyword" },
-             "comments" : { <1>
-                 "type" : "nested",
-                 "properties" : {
-                     "username" : { "type" : "keyword" },
-                     "comment" : { "type" : "text" }
-                 }
-             }
-         }
+  "mappings": {
+    "properties": {
+      "tags": { "type": "keyword" },
+      "comments": {                            <1>
+        "type": "nested",
+        "properties": {
+          "username": { "type": "keyword" },
+          "comment": { "type": "text" }
+        }
+      }
     }
+  }
 }
 --------------------------------------------------
 

+ 79 - 79
docs/reference/aggregations/bucket/sampler-aggregation.asciidoc

@@ -19,26 +19,26 @@ the most interesting parts of our query we use a sample.
 --------------------------------------------------
 POST /stackoverflow/_search?size=0
 {
-    "query": {
-        "query_string": {
-            "query": "tags:kibana OR tags:javascript"
-        }
-    },
-    "aggs": {
-        "sample": {
-            "sampler": {
-                "shard_size": 200
-            },
-            "aggs": {
-                "keywords": {
-                    "significant_terms": {
-                        "field": "tags",
-                        "exclude": ["kibana", "javascript"]
-                    }
-                }
-            }
+  "query": {
+    "query_string": {
+      "query": "tags:kibana OR tags:javascript"
+    }
+  },
+  "aggs": {
+    "sample": {
+      "sampler": {
+        "shard_size": 200
+      },
+      "aggs": {
+        "keywords": {
+          "significant_terms": {
+            "field": "tags",
+            "exclude": [ "kibana", "javascript" ]
+          }
         }
+      }
     }
+  }
 }
 --------------------------------------------------
 // TEST[setup:stackoverflow]
@@ -48,30 +48,30 @@ Response:
 [source,console-result]
 --------------------------------------------------
 {
-    ...
-    "aggregations": {
-        "sample": {
-            "doc_count": 200,<1>
-            "keywords": {
-                "doc_count": 200,
-                "bg_count": 650,
-                "buckets": [
-                    {
-                        "key": "elasticsearch",
-                        "doc_count": 150,
-                        "score": 1.078125,
-                        "bg_count": 200
-                    },
-                    {
-                        "key": "logstash",
-                        "doc_count": 50,
-                        "score": 0.5625,
-                        "bg_count": 50
-                    }
-                ]
-            }
-        }
+  ...
+  "aggregations": {
+    "sample": {
+      "doc_count": 200, <1>
+      "keywords": {
+        "doc_count": 200,
+        "bg_count": 650,
+        "buckets": [
+          {
+            "key": "elasticsearch",
+            "doc_count": 150,
+            "score": 1.078125,
+            "bg_count": 200
+          },
+          {
+            "key": "logstash",
+            "doc_count": 50,
+            "score": 0.5625,
+            "bg_count": 50
+          }
+        ]
+      }
     }
+  }
 }
 --------------------------------------------------
 // TESTRESPONSE[s/\.\.\./"took": $body.took,"timed_out": false,"_shards": $body._shards,"hits": $body.hits,/]
@@ -88,20 +88,20 @@ less significant terms such as `jquery` and `angular` rather than focusing on th
 --------------------------------------------------
 POST /stackoverflow/_search?size=0
 {
-    "query": {
-        "query_string": {
-            "query": "tags:kibana OR tags:javascript"
-        }
-    },
-    "aggs": {
-             "low_quality_keywords": {
-                "significant_terms": {
-                    "field": "tags",
-                    "size": 3,
-                    "exclude":["kibana", "javascript"]
-                }
-        }
+  "query": {
+    "query_string": {
+      "query": "tags:kibana OR tags:javascript"
+    }
+  },
+  "aggs": {
+    "low_quality_keywords": {
+      "significant_terms": {
+        "field": "tags",
+        "size": 3,
+        "exclude": [ "kibana", "javascript" ]
+      }
     }
+  }
 }
 --------------------------------------------------
 // TEST[setup:stackoverflow]
@@ -111,33 +111,33 @@ Response:
 [source,console-result]
 --------------------------------------------------
 {
-    ...
-    "aggregations": {
-        "low_quality_keywords": {
-            "doc_count": 600,
-            "bg_count": 650,
-            "buckets": [
-                {
-                    "key": "angular",
-                    "doc_count": 200,
-                    "score": 0.02777,
-                    "bg_count": 200
-                },
-                {
-                    "key": "jquery",
-                    "doc_count": 200,
-                    "score": 0.02777,
-                    "bg_count": 200
-                },
-                {
-                    "key": "logstash",
-                    "doc_count": 50,
-                    "score": 0.0069,
-                    "bg_count": 50
-                }
-            ]
+  ...
+  "aggregations": {
+    "low_quality_keywords": {
+      "doc_count": 600,
+      "bg_count": 650,
+      "buckets": [
+        {
+          "key": "angular",
+          "doc_count": 200,
+          "score": 0.02777,
+          "bg_count": 200
+        },
+        {
+          "key": "jquery",
+          "doc_count": 200,
+          "score": 0.02777,
+          "bg_count": 200
+        },
+        {
+          "key": "logstash",
+          "doc_count": 50,
+          "score": 0.0069,
+          "bg_count": 50
         }
+      ]
     }
+  }
 }
 --------------------------------------------------
 // TESTRESPONSE[s/\.\.\./"took": $body.took,"timed_out": false,"_shards": $body._shards,"hits": $body.hits,/]

+ 76 - 76
docs/reference/aggregations/bucket/significantterms-aggregation.asciidoc

@@ -21,16 +21,16 @@ that is significant and probably very relevant to their search. 5/10,000,000 vs
 --------------------------------------------------
 PUT /reports
 {
-    "mappings": {
-        "properties": {
-            "force": {
-                "type": "keyword"
-            },
-            "crime_type": {
-                "type": "keyword"
-            }
-        }
+  "mappings": {
+    "properties": {
+      "force": {
+        "type": "keyword"
+      },
+      "crime_type": {
+        "type": "keyword"
+      }
     }
+  }
 }
 
 POST /reports/_bulk?refresh
@@ -67,14 +67,14 @@ Example:
 --------------------------------------------------
 GET /_search
 {
-    "query" : {
-        "terms" : {"force" : [ "British Transport Police" ]}
-    },
-    "aggregations" : {
-        "significant_crime_types" : {
-            "significant_terms" : { "field" : "crime_type" }
-        }
+  "query": {
+    "terms": { "force": [ "British Transport Police" ] }
+  },
+  "aggregations": {
+    "significant_crime_types": {
+      "significant_terms": { "field": "crime_type" }
     }
+  }
 }
 --------------------------------------------------
 // TEST[s/_search/_search\?filter_path=aggregations/]
@@ -84,22 +84,22 @@ Response:
 [source,console-result]
 --------------------------------------------------
 {
-    ...
-    "aggregations" : {
-        "significant_crime_types" : {
-            "doc_count": 47347,
-            "bg_count": 5064554,
-            "buckets" : [
-                {
-                    "key": "Bicycle theft",
-                    "doc_count": 3640,
-                    "score": 0.371235374214817,
-                    "bg_count": 66799
-                }
-                ...
-            ]
+  ...
+  "aggregations": {
+    "significant_crime_types": {
+      "doc_count": 47347,
+      "bg_count": 5064554,
+      "buckets": [
+        {
+          "key": "Bicycle theft",
+          "doc_count": 3640,
+          "score": 0.371235374214817,
+          "bg_count": 66799
         }
+              ...
+      ]
     }
+  }
 }
 --------------------------------------------------
 // TESTRESPONSE[s/\.\.\.//]
@@ -127,16 +127,16 @@ Example using a parent aggregation for segmentation:
 --------------------------------------------------
 GET /_search
 {
-    "aggregations": {
-        "forces": {
-            "terms": {"field": "force"},
-            "aggregations": {
-                "significant_crime_types": {
-                    "significant_terms": {"field": "crime_type"}
-                }
-            }
+  "aggregations": {
+    "forces": {
+      "terms": { "field": "force" },
+      "aggregations": {
+        "significant_crime_types": {
+          "significant_terms": { "field": "crime_type" }
         }
+      }
     }
+  }
 }
 --------------------------------------------------
 // TEST[s/_search/_search\?filter_path=aggregations/]
@@ -204,19 +204,19 @@ area to identify unusual hot-spots of a particular crime type:
 --------------------------------------------------
 GET /_search
 {
-    "aggs": {
-        "hotspots": {
-            "geohash_grid": {
-                "field": "location",
-                "precision": 5
-            },
-            "aggs": {
-                "significant_crime_types": {
-                    "significant_terms": {"field": "crime_type"}
-                }
-            }
+  "aggs": {
+    "hotspots": {
+      "geohash_grid": {
+        "field": "location",
+        "precision": 5
+      },
+      "aggs": {
+        "significant_crime_types": {
+          "significant_terms": { "field": "crime_type" }
         }
+      }
     }
+  }
 }
 --------------------------------------------------
 
@@ -464,14 +464,14 @@ It is possible to only return terms that match more than a configured number of
 --------------------------------------------------
 GET /_search
 {
-    "aggs" : {
-        "tags" : {
-            "significant_terms" : {
-                "field" : "tag",
-                "min_doc_count": 10
-            }
-        }
+  "aggs": {
+    "tags": {
+      "significant_terms": {
+        "field": "tag",
+        "min_doc_count": 10
+      }
     }
+  }
 }
 --------------------------------------------------
 
@@ -507,21 +507,21 @@ context:
 --------------------------------------------------
 GET /_search
 {
-    "query" : {
-        "match" : {
-            "city" : "madrid"
-        }
-    },
-    "aggs" : {
-        "tags" : {
-            "significant_terms" : {
-                "field" : "tag",
-                "background_filter": {
-                	"term" : { "text" : "spain"}
-                }
-            }
+  "query": {
+    "match": {
+      "city": "madrid"
+    }
+  },
+  "aggs": {
+    "tags": {
+      "significant_terms": {
+        "field": "tag",
+        "background_filter": {
+          "term": { "text": "spain" }
         }
+      }
     }
+  }
 }
 --------------------------------------------------
 
@@ -565,14 +565,14 @@ ordinals.
 --------------------------------------------------
 GET /_search
 {
-    "aggs" : {
-        "tags" : {
-             "significant_terms" : {
-                 "field" : "tags",
-                 "execution_hint": "map" <1>
-             }
-         }
+  "aggs": {
+    "tags": {
+      "significant_terms": {
+        "field": "tags",
+        "execution_hint": "map" <1>
+      }
     }
+  }
 }
 --------------------------------------------------
 

+ 39 - 39
docs/reference/aggregations/bucket/significanttext-aggregation.asciidoc

@@ -36,21 +36,21 @@ Example:
 --------------------------------------------------
 GET news/_search
 {
-    "query" : {
-        "match" : {"content" : "Bird flu"}
-    },
-    "aggregations" : {
-        "my_sample" : {
-            "sampler" : {
-                "shard_size" : 100
-            },
-            "aggregations": {
-                "keywords" : {
-                    "significant_text" : { "field" : "content" }
-                }
-            }
+  "query": {
+    "match": { "content": "Bird flu" }
+  },
+  "aggregations": {
+    "my_sample": {
+      "sampler": {
+        "shard_size": 100
+      },
+      "aggregations": {
+        "keywords": {
+          "significant_text": { "field": "content" }
         }
+      }
     }
+  }
 }
 --------------------------------------------------
 // TEST[setup:news]
@@ -109,7 +109,7 @@ mentioning "elasticsearch":
 [source,js]
 --------------------------------------------------
 {
-    ...
+  ...
   "aggregations": {
     "sample": {
       "doc_count": 35,
@@ -420,21 +420,21 @@ context:
 --------------------------------------------------
 GET news/_search
 {
-    "query" : {
-        "match" : {
-            "content" : "madrid"
-        }
-    },
-    "aggs" : {
-        "tags" : {
-            "significant_text" : {
-                "field" : "content",
-                "background_filter": {
-                    "term" : { "content" : "spain"}
-                }
-            }
+  "query": {
+    "match": {
+      "content": "madrid"
+    }
+  },
+  "aggs": {
+    "tags": {
+      "significant_text": {
+        "field": "content",
+        "background_filter": {
+          "term": { "content": "spain" }
         }
+      }
     }
+  }
 }
 --------------------------------------------------
 // TEST[setup:news]
@@ -458,19 +458,19 @@ will be analyzed using the `source_fields` parameter:
 --------------------------------------------------
 GET news/_search
 {
-    "query" : {
-        "match" : {
-            "custom_all" : "elasticsearch"
-        }
-    },
-    "aggs" : {
-        "tags" : {
-            "significant_text" : {
-                "field" : "custom_all",
-                "source_fields": ["content" , "title"]
-            }
-        }
+  "query": {
+    "match": {
+      "custom_all": "elasticsearch"
     }
+  },
+  "aggs": {
+    "tags": {
+      "significant_text": {
+        "field": "custom_all",
+        "source_fields": [ "content", "title" ]
+      }
+    }
+  }
 }
 --------------------------------------------------
 // TEST[setup:news]

+ 202 - 202
docs/reference/aggregations/bucket/terms-aggregation.asciidoc

@@ -9,16 +9,16 @@ A multi-bucket value source based aggregation where buckets are dynamically buil
 --------------------------------------------------
 PUT /products
 {
-    "mappings": {
-        "properties": {
-            "genre": {
-                "type": "keyword"
-            },
-            "product": {
-                "type": "keyword"
-            }
-        }
+  "mappings": {
+    "properties": {
+      "genre": {
+        "type": "keyword"
+      },
+      "product": {
+        "type": "keyword"
+      }
     }
+  }
 }
 
 POST /products/_bulk?refresh
@@ -57,11 +57,11 @@ Example:
 --------------------------------------------------
 GET /_search
 {
-    "aggs" : {
-        "genres" : {
-            "terms" : { "field" : "genre" } <1>
-        }
+  "aggs": {
+    "genres": {
+      "terms": { "field": "genre" } <1>
     }
+  }
 }
 --------------------------------------------------
 // TEST[s/_search/_search\?filter_path=aggregations/]
@@ -74,27 +74,27 @@ Response:
 [source,console-result]
 --------------------------------------------------
 {
-    ...
-    "aggregations" : {
-        "genres" : {
-            "doc_count_error_upper_bound": 0, <1>
-            "sum_other_doc_count": 0, <2>
-            "buckets" : [ <3>
-                {
-                    "key" : "electronic",
-                    "doc_count" : 6
-                },
-                {
-                    "key" : "rock",
-                    "doc_count" : 3
-                },
-                {
-                    "key" : "jazz",
-                    "doc_count" : 2
-                }
-            ]
+  ...
+  "aggregations": {
+    "genres": {
+      "doc_count_error_upper_bound": 0,   <1>
+      "sum_other_doc_count": 0,           <2>
+      "buckets": [                        <3>
+        {
+          "key": "electronic",
+          "doc_count": 6
+        },
+        {
+          "key": "rock",
+          "doc_count": 3
+        },
+        {
+          "key": "jazz",
+          "doc_count": 2
         }
+      ]
     }
+  }
 }
 --------------------------------------------------
 // TESTRESPONSE[s/\.\.\.//]
@@ -162,15 +162,15 @@ The second error value can be enabled by setting the `show_term_doc_count_error`
 --------------------------------------------------
 GET /_search
 {
-    "aggs" : {
-        "products" : {
-            "terms" : {
-                "field" : "product",
-                "size" : 5,
-                "show_term_doc_count_error": true
-            }
-        }
+  "aggs": {
+    "products": {
+      "terms": {
+        "field": "product",
+        "size": 5,
+        "show_term_doc_count_error": true
+      }
     }
+  }
 }
 --------------------------------------------------
 // TEST[s/_search/_search\?filter_path=aggregations/]
@@ -207,14 +207,14 @@ Ordering the buckets by their doc `_count` in an ascending manner:
 --------------------------------------------------
 GET /_search
 {
-    "aggs" : {
-        "genres" : {
-            "terms" : {
-                "field" : "genre",
-                "order" : { "_count" : "asc" }
-            }
-        }
+  "aggs": {
+    "genres": {
+      "terms": {
+        "field": "genre",
+        "order": { "_count": "asc" }
+      }
     }
+  }
 }
 --------------------------------------------------
 
@@ -224,14 +224,14 @@ Ordering the buckets alphabetically by their terms in an ascending manner:
 --------------------------------------------------
 GET /_search
 {
-    "aggs" : {
-        "genres" : {
-            "terms" : {
-                "field" : "genre",
-                "order" : { "_key" : "asc" }
-            }
-        }
+  "aggs": {
+    "genres": {
+      "terms": {
+        "field": "genre",
+        "order": { "_key": "asc" }
+      }
     }
+  }
 }
 --------------------------------------------------
 
@@ -243,17 +243,17 @@ Ordering the buckets by single value metrics sub-aggregation (identified by the
 --------------------------------------------------
 GET /_search
 {
-    "aggs" : {
-        "genres" : {
-            "terms" : {
-                "field" : "genre",
-                "order" : { "max_play_count" : "desc" }
-            },
-            "aggs" : {
-                "max_play_count" : { "max" : { "field" : "play_count" } }
-            }
-        }
+  "aggs": {
+    "genres": {
+      "terms": {
+        "field": "genre",
+        "order": { "max_play_count": "desc" }
+      },
+      "aggs": {
+        "max_play_count": { "max": { "field": "play_count" } }
+      }
     }
+  }
 }
 --------------------------------------------------
 
@@ -263,17 +263,17 @@ Ordering the buckets by multi value metrics sub-aggregation (identified by the a
 --------------------------------------------------
 GET /_search
 {
-    "aggs" : {
-        "genres" : {
-            "terms" : {
-                "field" : "genre",
-                "order" : { "playback_stats.max" : "desc" }
-            },
-            "aggs" : {
-                "playback_stats" : { "stats" : { "field" : "play_count" } }
-            }
-        }
+  "aggs": {
+    "genres": {
+      "terms": {
+        "field": "genre",
+        "order": { "playback_stats.max": "desc" }
+      },
+      "aggs": {
+        "playback_stats": { "stats": { "field": "play_count" } }
+      }
     }
+  }
 }
 --------------------------------------------------
 
@@ -309,22 +309,22 @@ PATH                =  <AGG_NAME> [ <AGG_SEPARATOR>, <AGG_NAME> ]* [ <METRIC_SEP
 --------------------------------------------------
 GET /_search
 {
-    "aggs" : {
-        "countries" : {
-            "terms" : {
-                "field" : "artist.country",
-                "order" : { "rock>playback_stats.avg" : "desc" }
-            },
-            "aggs" : {
-                "rock" : {
-                    "filter" : { "term" : { "genre" :  "rock" }},
-                    "aggs" : {
-                        "playback_stats" : { "stats" : { "field" : "play_count" }}
-                    }
-                }
-            }
+  "aggs": {
+    "countries": {
+      "terms": {
+        "field": "artist.country",
+        "order": { "rock>playback_stats.avg": "desc" }
+      },
+      "aggs": {
+        "rock": {
+          "filter": { "term": { "genre": "rock" } },
+          "aggs": {
+            "playback_stats": { "stats": { "field": "play_count" } }
+          }
         }
+      }
     }
+  }
 }
 --------------------------------------------------
 
@@ -336,22 +336,22 @@ Multiple criteria can be used to order the buckets by providing an array of orde
 --------------------------------------------------
 GET /_search
 {
-    "aggs" : {
-        "countries" : {
-            "terms" : {
-                "field" : "artist.country",
-                "order" : [ { "rock>playback_stats.avg" : "desc" }, { "_count" : "desc" } ]
-            },
-            "aggs" : {
-                "rock" : {
-                    "filter" : { "term" : { "genre" : "rock" }},
-                    "aggs" : {
-                        "playback_stats" : { "stats" : { "field" : "play_count" }}
-                    }
-                }
-            }
+  "aggs": {
+    "countries": {
+      "terms": {
+        "field": "artist.country",
+        "order": [ { "rock>playback_stats.avg": "desc" }, { "_count": "desc" } ]
+      },
+      "aggs": {
+        "rock": { 
+          "filter": { "term": { "genre": "rock" } },
+          "aggs": {
+            "playback_stats": { "stats": { "field": "play_count" } } 
+          }
         }
+      }
     }
+  }
 }
 --------------------------------------------------
 
@@ -369,14 +369,14 @@ It is possible to only return terms that match more than a configured number of
 --------------------------------------------------
 GET /_search
 {
-    "aggs" : {
-        "tags" : {
-            "terms" : {
-                "field" : "tags",
-                "min_doc_count": 10
-            }
-        }
+  "aggs": {
+    "tags": {
+      "terms": {
+        "field": "tags",
+        "min_doc_count": 10
+      }
     }
+  }
 }
 --------------------------------------------------
 
@@ -410,16 +410,16 @@ Generating the terms using a script:
 --------------------------------------------------
 GET /_search
 {
-    "aggs" : {
-        "genres" : {
-            "terms" : {
-                "script" : {
-                    "source": "doc['genre'].value",
-                    "lang": "painless"
-                }
-            }
+  "aggs": {
+    "genres": {
+      "terms": {
+        "script": {
+          "source": "doc['genre'].value",
+          "lang": "painless"
         }
+      }
     }
+  }
 }
 --------------------------------------------------
 
@@ -444,18 +444,18 @@ POST /_scripts/my_script
 --------------------------------------------------
 GET /_search
 {
-    "aggs" : {
-        "genres" : {
-            "terms" : {
-                "script" : {
-                    "id": "my_script",
-                    "params": {
-                        "field": "genre"
-                    }
-                }
-            }
+  "aggs": {
+    "genres": {
+      "terms": {
+        "script": {
+          "id": "my_script",
+          "params": {
+            "field": "genre"
+          }
         }
+      }
     }
+  }
 }
 --------------------------------------------------
 // TEST[continued]
@@ -466,17 +466,17 @@ GET /_search
 --------------------------------------------------
 GET /_search
 {
-    "aggs" : {
-        "genres" : {
-            "terms" : {
-                "field" : "genre",
-                "script" : {
-                    "source" : "'Genre: ' +_value",
-                    "lang" : "painless"
-                }
-            }
+  "aggs": {
+    "genres": {
+      "terms": {
+        "field": "genre",
+        "script": {
+          "source": "'Genre: ' +_value",
+          "lang": "painless"
         }
+      }
     }
+  }
 }
 --------------------------------------------------
 
@@ -492,15 +492,15 @@ It is possible to filter the values for which buckets will be created. This can
 --------------------------------------------------
 GET /_search
 {
-    "aggs" : {
-        "tags" : {
-            "terms" : {
-                "field" : "tags",
-                "include" : ".*sport.*",
-                "exclude" : "water_.*"
-            }
-        }
+  "aggs": {
+    "tags": {
+      "terms": {
+        "field": "tags",
+        "include": ".*sport.*",
+        "exclude": "water_.*"
+      }
     }
+  }
 }
 --------------------------------------------------
 
@@ -520,20 +520,20 @@ strings that represent the terms as they are found in the index:
 --------------------------------------------------
 GET /_search
 {
-    "aggs" : {
-        "JapaneseCars" : {
-             "terms" : {
-                 "field" : "make",
-                 "include" : ["mazda", "honda"]
-             }
-         },
-        "ActiveCarManufacturers" : {
-             "terms" : {
-                 "field" : "make",
-                 "exclude" : ["rover", "jensen"]
-             }
-         }
+  "aggs": {
+    "JapaneseCars": {
+      "terms": {
+        "field": "make",
+        "include": [ "mazda", "honda" ]
+      }
+    },
+    "ActiveCarManufacturers": {
+      "terms": {
+        "field": "make",
+        "exclude": [ "rover", "jensen" ]
+      }
     }
+  }
 }
 --------------------------------------------------
 
@@ -641,22 +641,22 @@ An example problem scenario is querying a movie database for the 10 most popular
 --------------------------------------------------
 GET /_search
 {
-    "aggs" : {
-        "actors" : {
-             "terms" : {
-                 "field" : "actors",
-                 "size" : 10
-             },
-            "aggs" : {
-                "costars" : {
-                     "terms" : {
-                         "field" : "actors",
-                         "size" : 5
-                     }
-                 }
-            }
-         }
+  "aggs": {
+    "actors": {
+      "terms": {
+        "field": "actors",
+        "size": 10
+      },
+      "aggs": {
+        "costars": {
+          "terms": {
+            "field": "actors",
+            "size": 5
+          }
+        }
+      }
     }
+  }
 }
 --------------------------------------------------
 
@@ -672,23 +672,23 @@ It is possible to override the default heuristic and to provide a collect mode d
 --------------------------------------------------
 GET /_search
 {
-    "aggs" : {
-        "actors" : {
-             "terms" : {
-                 "field" : "actors",
-                 "size" : 10,
-                 "collect_mode" : "breadth_first" <1>
-             },
-            "aggs" : {
-                "costars" : {
-                     "terms" : {
-                         "field" : "actors",
-                         "size" : 5
-                     }
-                 }
-            }
-         }
+  "aggs": {
+    "actors": {
+      "terms": {
+        "field": "actors",
+        "size": 10,
+        "collect_mode": "breadth_first" <1>
+      },
+      "aggs": {
+        "costars": {
+          "terms": {
+            "field": "actors",
+            "size": 5
+          }
+        }
+      }
     }
+  }
 }
 --------------------------------------------------
 
@@ -723,14 +723,14 @@ ordinals.
 --------------------------------------------------
 GET /_search
 {
-    "aggs" : {
-        "tags" : {
-             "terms" : {
-                 "field" : "tags",
-                 "execution_hint": "map" <1>
-             }
-         }
+  "aggs": {
+    "tags": {
+      "terms": {
+        "field": "tags",
+        "execution_hint": "map" <1>
+      }
     }
+  }
 }
 --------------------------------------------------
 
@@ -748,14 +748,14 @@ had a value.
 --------------------------------------------------
 GET /_search
 {
-    "aggs" : {
-        "tags" : {
-             "terms" : {
-                 "field" : "tags",
-                 "missing": "N/A" <1>
-             }
-         }
+  "aggs": {
+    "tags": {
+      "terms": {
+        "field": "tags",
+        "missing": "N/A" <1>
+      }
     }
+  }
 }
 --------------------------------------------------
 

+ 24 - 24
docs/reference/aggregations/bucket/variablewidthhistogram-aggregation.asciidoc

@@ -17,14 +17,14 @@ Requesting a target of 2 buckets.
 --------------------------------------------------
 POST /sales/_search?size=0
 {
-    "aggs" : {
-        "prices" : {
-            "variable_width_histogram" : {
-                "field" : "price",
-                "buckets" : 2
-            }
-        }
+  "aggs": {
+    "prices": {
+      "variable_width_histogram": {
+        "field": "price",
+        "buckets": 2
+      }
     }
+  }
 }
 --------------------------------------------------
 // TEST[setup:sales]
@@ -34,25 +34,25 @@ Response:
 [source,console-result]
 --------------------------------------------------
 {
-    ...
-    "aggregations": {
-        "prices" : {
-            "buckets": [
-                {
-                    "min": 10.0,
-                    "key": 30.0,
-                    "max": 50.0,
-                    "doc_count": 2
-                },
-                {
-                    "min": 150.0,
-                    "key": 185.0,
-                    "max": 200.0,
-                    "doc_count": 5
-                }
-            ]
+  ...
+  "aggregations": {
+    "prices": {
+      "buckets": [
+        {
+          "min": 10.0,
+          "key": 30.0,
+          "max": 50.0,
+          "doc_count": 2
+        },
+        {
+          "min": 150.0,
+          "key": 185.0,
+          "max": 200.0,
+          "doc_count": 5
         }
+      ]
     }
+  }
 }
 --------------------------------------------------
 // TESTRESPONSE[s/\.\.\./"took": $body.took,"timed_out": false,"_shards": $body._shards,"hits": $body.hits,/]

+ 49 - 49
docs/reference/aggregations/matrix/stats-aggregation.asciidoc

@@ -39,13 +39,13 @@ The following example demonstrates the use of matrix stats to describe the relat
 --------------------------------------------------
 GET /_search
 {
-    "aggs": {
-        "statistics": {
-            "matrix_stats": {
-                "fields": ["poverty", "income"]
-            }
-        }
+  "aggs": {
+    "statistics": {
+      "matrix_stats": {
+        "fields": [ "poverty", "income" ]
+      }
     }
+  }
 }
 --------------------------------------------------
 // TEST[s/_search/_search\?filter_path=aggregations/]
@@ -56,43 +56,43 @@ the statistics. The above request returns the following response:
 [source,console-result]
 --------------------------------------------------
 {
-    ...
-    "aggregations": {
-        "statistics": {
-            "doc_count": 50,
-            "fields": [{
-                "name": "income",
-                "count": 50,
-                "mean": 51985.1,
-                "variance": 7.383377037755103E7,
-                "skewness": 0.5595114003506483,
-                "kurtosis": 2.5692365287787124,
-                "covariance": {
-                    "income": 7.383377037755103E7,
-                    "poverty": -21093.65836734694
-                },
-                "correlation": {
-                    "income": 1.0,
-                    "poverty": -0.8352655256272504
-                }
-            }, {
-                "name": "poverty",
-                "count": 50,
-                "mean": 12.732000000000001,
-                "variance": 8.637730612244896,
-                "skewness": 0.4516049811903419,
-                "kurtosis": 2.8615929677997767,
-                "covariance": {
-                    "income": -21093.65836734694,
-                    "poverty": 8.637730612244896
-                },
-                "correlation": {
-                    "income": -0.8352655256272504,
-                    "poverty": 1.0
-                }
-            }]
-        }
+  ...
+  "aggregations": {
+    "statistics": {
+      "doc_count": 50,
+      "fields": [ {
+          "name": "income",
+          "count": 50,
+          "mean": 51985.1,
+          "variance": 7.383377037755103E7,
+          "skewness": 0.5595114003506483,
+          "kurtosis": 2.5692365287787124,
+          "covariance": {
+            "income": 7.383377037755103E7,
+            "poverty": -21093.65836734694
+          },
+          "correlation": {
+            "income": 1.0,
+            "poverty": -0.8352655256272504
+          }
+        }, {
+          "name": "poverty",
+          "count": 50,
+          "mean": 12.732000000000001,
+          "variance": 8.637730612244896,
+          "skewness": 0.4516049811903419,
+          "kurtosis": 2.8615929677997767,
+          "covariance": {
+            "income": -21093.65836734694,
+            "poverty": 8.637730612244896
+          },
+          "correlation": {
+            "income": -0.8352655256272504,
+            "poverty": 1.0
+          }
+        } ]
     }
+  }
 }
 --------------------------------------------------
 // TESTRESPONSE[s/\.\.\.//]
@@ -122,14 +122,14 @@ This is done by adding a set of fieldname : value mappings to specify default va
 --------------------------------------------------
 GET /_search
 {
-    "aggs": {
-        "matrixstats": {
-            "matrix_stats": {
-                "fields": ["poverty", "income"],
-                "missing": {"income" : 50000} <1>
-            }
-        }
+  "aggs": {
+    "matrixstats": {
+      "matrix_stats": {
+        "fields": [ "poverty", "income" ],
+        "missing": { "income": 50000 }      <1>
+      }
     }
+  }
 }
 --------------------------------------------------
 

+ 53 - 53
docs/reference/aggregations/metrics/avg-aggregation.asciidoc

@@ -10,9 +10,9 @@ and 100) of students we can average their scores with:
 --------------------------------------------------
 POST /exams/_search?size=0
 {
-    "aggs" : {
-        "avg_grade" : { "avg" : { "field" : "grade" } }
-    }
+  "aggs": {
+    "avg_grade": { "avg": { "field": "grade" } }
+  }
 }
 --------------------------------------------------
 // TEST[setup:exams]
@@ -22,12 +22,12 @@ The above aggregation computes the average grade over all documents. The aggrega
 [source,console-result]
 --------------------------------------------------
 {
-    ...
-    "aggregations": {
-        "avg_grade": {
-            "value": 75.0
-        }
+  ...
+  "aggregations": {
+    "avg_grade": {
+      "value": 75.0
     }
+  }
 }
 --------------------------------------------------
 // TESTRESPONSE[s/\.\.\./"took": $body.took,"timed_out": false,"_shards": $body._shards,"hits": $body.hits,/]
@@ -42,15 +42,15 @@ Computing the average grade based on a script:
 --------------------------------------------------
 POST /exams/_search?size=0
 {
-    "aggs" : {
-        "avg_grade" : {
-            "avg" : {
-                "script" : {
-                    "source" : "doc.grade.value"
-                }
-            }
+  "aggs": {
+    "avg_grade": {
+      "avg": {
+        "script": {
+          "source": "doc.grade.value"
         }
+      }
     }
+  }
 }
 --------------------------------------------------
 // TEST[setup:exams]
@@ -61,18 +61,18 @@ This will interpret the `script` parameter as an `inline` script with the `painl
 --------------------------------------------------
 POST /exams/_search?size=0
 {
-    "aggs" : {
-        "avg_grade" : {
-            "avg" : {
-                "script" : {
-                    "id": "my_script",
-                    "params": {
-                        "field": "grade"
-                    }
-                }
-            }
+  "aggs": {
+    "avg_grade": {
+      "avg": {
+        "script": {
+          "id": "my_script",
+          "params": {
+            "field": "grade"
+          }
         }
+      }
     }
+  }
 }
 --------------------------------------------------
 // TEST[setup:exams,stored_example_script]
@@ -85,20 +85,20 @@ It turned out that the exam was way above the level of the students and a grade
 --------------------------------------------------
 POST /exams/_search?size=0
 {
-    "aggs" : {
-        "avg_corrected_grade" : {
-            "avg" : {
-                "field" : "grade",
-                "script" : {
-                    "lang": "painless",
-                    "source": "_value * params.correction",
-                    "params" : {
-                        "correction" : 1.2
-                    }
-                }
-            }
+  "aggs": {
+    "avg_corrected_grade": {
+      "avg": {
+        "field": "grade",
+        "script": {
+          "lang": "painless",
+          "source": "_value * params.correction",
+          "params": {
+            "correction": 1.2
+          }
         }
+      }
     }
+  }
 }
 --------------------------------------------------
 // TEST[setup:exams]
@@ -113,14 +113,14 @@ had a value.
 --------------------------------------------------
 POST /exams/_search?size=0
 {
-    "aggs" : {
-        "grade_avg" : {
-            "avg" : {
-                "field" : "grade",
-                "missing": 10 <1>
-            }
-        }
+  "aggs": {
+    "grade_avg": {
+      "avg": {
+        "field": "grade",
+        "missing": 10     <1>
+      }
     }
+  }
 }
 --------------------------------------------------
 // TEST[setup:exams]
@@ -157,11 +157,11 @@ PUT metrics_index/_doc/2
 
 POST /metrics_index/_search?size=0
 {
-    "aggs" : {
-        "avg_latency" :
-            { "avg" : { "field" : "latency_histo" }
-        }
+  "aggs": {
+    "avg_latency": 
+      { "avg": { "field": "latency_histo" } 
     }
+  }
 }
 --------------------------------------------------
 
@@ -171,12 +171,12 @@ in the `counts` array <2>. Eventually, it will compute the average over those va
 [source,console-result]
 --------------------------------------------------
 {
-    ...
-    "aggregations" : {
-        "avg_latency" : {
-           "value" : 0.29690721649
-        }
+  ...
+  "aggregations": {
+    "avg_latency": {
+      "value": 0.29690721649
     }
+  }
 }
 --------------------------------------------------
 // TESTRESPONSE[skip:test not setup]

+ 60 - 60
docs/reference/aggregations/metrics/boxplot-aggregation.asciidoc

@@ -17,9 +17,9 @@ A `boxplot` aggregation looks like this in isolation:
 [source,js]
 --------------------------------------------------
 {
-    "boxplot": {
-        "field": "load_time"
-    }
+  "boxplot": {
+    "field": "load_time"
+  }
 }
 --------------------------------------------------
 // NOTCONSOLE
@@ -30,14 +30,14 @@ Let's look at a boxplot representing load time:
 --------------------------------------------------
 GET latency/_search
 {
-    "size": 0,
-    "aggs" : {
-        "load_time_boxplot" : {
-            "boxplot" : {
-                "field" : "load_time" <1>
-            }
-        }
+  "size": 0,
+  "aggs": {
+    "load_time_boxplot": {
+      "boxplot": {
+        "field": "load_time" <1>
+      }
     }
+  }
 }
 --------------------------------------------------
 // TEST[setup:latency]
@@ -48,17 +48,17 @@ The response will look like this:
 [source,console-result]
 --------------------------------------------------
 {
-    ...
-
-   "aggregations": {
-      "load_time_boxplot": {
-         "min": 0.0,
-         "max": 990.0,
-         "q1": 165.0,
-         "q2": 445.0,
-         "q3": 725.0
-      }
-   }
+  ...
+
+ "aggregations": {
+    "load_time_boxplot": {
+      "min": 0.0,
+      "max": 990.0,
+      "q1": 165.0,
+      "q2": 445.0,
+      "q3": 725.0
+    }
+  }
 }
 --------------------------------------------------
 // TESTRESPONSE[s/\.\.\./"took": $body.took,"timed_out": false,"_shards": $body._shards,"hits": $body.hits,/]
@@ -73,20 +73,20 @@ a script to convert them on-the-fly:
 --------------------------------------------------
 GET latency/_search
 {
-    "size": 0,
-    "aggs" : {
-        "load_time_boxplot" : {
-            "boxplot" : {
-                "script" : {
-                    "lang": "painless",
-                    "source": "doc['load_time'].value / params.timeUnit", <1>
-                    "params" : {
-                        "timeUnit" : 1000   <2>
-                    }
-                }
-            }
+  "size": 0,
+  "aggs": {
+    "load_time_boxplot": {
+      "boxplot": {
+        "script": {
+          "lang": "painless",
+          "source": "doc['load_time'].value / params.timeUnit", <1>
+          "params": {
+            "timeUnit": 1000                                    <2>
+          }
         }
+      }
     }
+  }
 }
 --------------------------------------------------
 // TEST[setup:latency]
@@ -102,19 +102,19 @@ stored script use the following syntax:
 --------------------------------------------------
 GET latency/_search
 {
-    "size": 0,
-    "aggs" : {
-        "load_time_boxplot" : {
-            "boxplot" : {
-                "script" : {
-                    "id": "my_script",
-                    "params": {
-                        "field": "load_time"
-                    }
-                }
-            }
+  "size": 0,
+  "aggs": {
+    "load_time_boxplot": {
+      "boxplot": {
+        "script": {
+          "id": "my_script",
+          "params": {
+            "field": "load_time"
+          }
         }
+      }
     }
+  }
 }
 --------------------------------------------------
 // TEST[setup:latency,stored_example_script]
@@ -143,15 +143,15 @@ This balance can be controlled using a `compression` parameter:
 --------------------------------------------------
 GET latency/_search
 {
-    "size": 0,
-    "aggs" : {
-        "load_time_boxplot" : {
-            "boxplot" : {
-                "field" : "load_time",
-                "compression" : 200 <1>
-            }
-        }
+  "size": 0,
+  "aggs": {
+    "load_time_boxplot": {
+      "boxplot": {
+        "field": "load_time",
+        "compression": 200    <1>
+      }
     }
+  }
 }
 --------------------------------------------------
 // TEST[setup:latency]
@@ -170,15 +170,15 @@ had a value.
 --------------------------------------------------
 GET latency/_search
 {
-    "size": 0,
-    "aggs" : {
-        "grade_boxplot" : {
-            "boxplot" : {
-                "field" : "grade",
-                "missing": 10 <1>
-            }
-        }
+  "size": 0,
+  "aggs": {
+    "grade_boxplot": {
+      "boxplot": {
+        "field": "grade",
+        "missing": 10     <1>
+      }
     }
+  }
 }
 --------------------------------------------------
 // TEST[setup:latency]

+ 44 - 44
docs/reference/aggregations/metrics/cardinality-aggregation.asciidoc

@@ -11,13 +11,13 @@ Assume you are indexing store sales and would like to count the unique number of
 --------------------------------------------------
 POST /sales/_search?size=0
 {
-    "aggs" : {
-        "type_count" : {
-            "cardinality" : {
-                "field" : "type"
-            }
-        }
+  "aggs": {
+    "type_count": {
+      "cardinality": {
+        "field": "type"
+      }
     }
+  }
 }
 --------------------------------------------------
 // TEST[setup:sales]
@@ -27,12 +27,12 @@ Response:
 [source,console-result]
 --------------------------------------------------
 {
-    ...
-    "aggregations" : {
-        "type_count" : {
-            "value" : 3
-        }
+  ...
+  "aggregations": {
+    "type_count": {
+      "value": 3
     }
+  }
 }
 --------------------------------------------------
 // TESTRESPONSE[s/\.\.\./"took": $body.took,"timed_out": false,"_shards": $body._shards,"hits": $body.hits,/]
@@ -45,14 +45,14 @@ This aggregation also supports the `precision_threshold` option:
 --------------------------------------------------
 POST /sales/_search?size=0
 {
-    "aggs" : {
-        "type_count" : {
-            "cardinality" : {
-                "field" : "type",
-                "precision_threshold": 100 <1>
-            }
-        }
+  "aggs": {
+    "type_count": {
+      "cardinality": {
+        "field": "type",
+        "precision_threshold": 100 <1>
+      }
     }
+  }
 }
 --------------------------------------------------
 // TEST[setup:sales]
@@ -185,16 +185,16 @@ however since hashes need to be computed on the fly.
 --------------------------------------------------
 POST /sales/_search?size=0
 {
-    "aggs" : {
-        "type_promoted_count" : {
-            "cardinality" : {
-                "script": {
-                    "lang": "painless",
-                    "source": "doc['type'].value + ' ' + doc['promoted'].value"
-                }
-            }
+  "aggs": {
+    "type_promoted_count": {
+      "cardinality": {
+        "script": {
+          "lang": "painless",
+          "source": "doc['type'].value + ' ' + doc['promoted'].value"
         }
+      }
     }
+  }
 }
 --------------------------------------------------
 // TEST[setup:sales]
@@ -205,19 +205,19 @@ This will interpret the `script` parameter as an `inline` script with the `painl
 --------------------------------------------------
 POST /sales/_search?size=0
 {
-    "aggs" : {
-        "type_promoted_count" : {
-            "cardinality" : {
-                "script" : {
-                    "id": "my_script",
-                    "params": {
-                        "type_field": "type",
-                        "promoted_field": "promoted"
-                    }
-                }
-            }
+  "aggs": {
+    "type_promoted_count": {
+      "cardinality": {
+        "script": {
+          "id": "my_script",
+          "params": {
+            "type_field": "type",
+            "promoted_field": "promoted"
+          }
         }
+      }
     }
+  }
 }
 --------------------------------------------------
 // TEST[skip:no script]
@@ -232,14 +232,14 @@ had a value.
 --------------------------------------------------
 POST /sales/_search?size=0
 {
-    "aggs" : {
-        "tag_cardinality" : {
-            "cardinality" : {
-                "field" : "tag",
-                "missing": "N/A" <1>
-            }
-        }
+  "aggs": {
+    "tag_cardinality": {
+      "cardinality": {
+        "field": "tag",
+        "missing": "N/A" <1>
+      }
     }
+  }
 }
 --------------------------------------------------
 // TEST[setup:sales]

+ 79 - 79
docs/reference/aggregations/metrics/extendedstats-aggregation.asciidoc

@@ -11,10 +11,10 @@ Assuming the data consists of documents representing exams grades (between 0 and
 --------------------------------------------------
 GET /exams/_search
 {
-    "size": 0,
-    "aggs" : {
-        "grades_stats" : { "extended_stats" : { "field" : "grade" } }
-    }
+  "size": 0,
+  "aggs": {
+    "grades_stats": { "extended_stats": { "field": "grade" } }
+  }
 }
 --------------------------------------------------
 // TEST[setup:exams]
@@ -26,32 +26,32 @@ The `std_deviation` and `variance` are calculated as population metrics so they
 [source,console-result]
 --------------------------------------------------
 {
-    ...
-
-    "aggregations": {
-        "grades_stats": {
-           "count": 2,
-           "min": 50.0,
-           "max": 100.0,
-           "avg": 75.0,
-           "sum": 150.0,
-           "sum_of_squares": 12500.0,
-           "variance": 625.0,
-           "variance_population": 625.0,
-           "variance_sampling": 1250.0,
-           "std_deviation": 25.0,
-           "std_deviation_population": 25.0,
-           "std_deviation_sampling": 35.35533905932738,
-           "std_deviation_bounds": {
-            "upper": 125.0,
-            "lower": 25.0,
-            "upper_population" : 125.0,
-            "lower_population" : 25.0,
-            "upper_sampling" : 145.71067811865476,
-            "lower_sampling" : 4.289321881345245
-           }
-        }
+  ...
+
+  "aggregations": {
+    "grades_stats": {
+      "count": 2,
+      "min": 50.0,
+      "max": 100.0,
+      "avg": 75.0,
+      "sum": 150.0,
+      "sum_of_squares": 12500.0,
+      "variance": 625.0,
+      "variance_population": 625.0,
+      "variance_sampling": 1250.0,
+      "std_deviation": 25.0,
+      "std_deviation_population": 25.0,
+      "std_deviation_sampling": 35.35533905932738,
+      "std_deviation_bounds": {
+        "upper": 125.0,
+        "lower": 25.0,
+        "upper_population": 125.0,
+        "lower_population": 25.0,
+        "upper_sampling": 145.71067811865476,
+        "lower_sampling": 4.289321881345245
+      }
     }
+  }
 }
 --------------------------------------------------
 // TESTRESPONSE[s/\.\.\./"took": $body.took,"timed_out": false,"_shards": $body._shards,"hits": $body.hits,/]
@@ -67,15 +67,15 @@ three standard deviations, you can set `sigma` in the request:
 --------------------------------------------------
 GET /exams/_search
 {
-    "size": 0,
-    "aggs" : {
-        "grades_stats" : {
-            "extended_stats" : {
-                "field" : "grade",
-                "sigma" : 3 <1>
-            }
-        }
+  "size": 0,
+  "aggs": {
+    "grades_stats": {
+      "extended_stats": {
+        "field": "grade",
+        "sigma": 3          <1>
+      }
     }
+  }
 }
 --------------------------------------------------
 // TEST[setup:exams]
@@ -103,17 +103,17 @@ Computing the grades stats based on a script:
 --------------------------------------------------
 GET /exams/_search
 {
-    "size": 0,
-    "aggs" : {
-        "grades_stats" : {
-            "extended_stats" : {
-                "script" : {
-                    "source" : "doc['grade'].value",
-                    "lang" : "painless"
-                 }
-             }
-         }
+  "size": 0,
+  "aggs": {
+    "grades_stats": {
+      "extended_stats": {
+        "script": {
+          "source": "doc['grade'].value",
+          "lang": "painless"
+        }
+      }
     }
+  }
 }
 --------------------------------------------------
 // TEST[setup:exams]
@@ -124,19 +124,19 @@ This will interpret the `script` parameter as an `inline` script with the `painl
 --------------------------------------------------
 GET /exams/_search
 {
-    "size": 0,
-    "aggs" : {
-        "grades_stats" : {
-            "extended_stats" : {
-                "script" : {
-                    "id": "my_script",
-                    "params": {
-                        "field": "grade"
-                    }
-                }
-            }
+  "size": 0,
+  "aggs": {
+    "grades_stats": {
+      "extended_stats": {
+        "script": {
+          "id": "my_script",
+          "params": {
+            "field": "grade"
+          }
         }
+      }
     }
+  }
 }
 --------------------------------------------------
 // TEST[setup:exams,stored_example_script]
@@ -149,21 +149,21 @@ It turned out that the exam was way above the level of the students and a grade
 --------------------------------------------------
 GET /exams/_search
 {
-    "size": 0,
-    "aggs" : {
-        "grades_stats" : {
-            "extended_stats" : {
-                "field" : "grade",
-                "script" : {
-                    "lang" : "painless",
-                    "source": "_value * params.correction",
-                    "params" : {
-                        "correction" : 1.2
-                    }
-                }
-            }
+  "size": 0,
+  "aggs": {
+    "grades_stats": {
+      "extended_stats": {
+        "field": "grade",
+        "script": {
+          "lang": "painless",
+          "source": "_value * params.correction",
+          "params": {
+            "correction": 1.2
+          }
         }
+      }
     }
+  }
 }
 --------------------------------------------------
 // TEST[setup:exams]
@@ -178,15 +178,15 @@ had a value.
 --------------------------------------------------
 GET /exams/_search
 {
-    "size": 0,
-    "aggs" : {
-        "grades_stats" : {
-            "extended_stats" : {
-                "field" : "grade",
-                "missing": 0 <1>
-            }
-        }
+  "size": 0,
+  "aggs": {
+    "grades_stats": {
+      "extended_stats": {
+        "field": "grade",
+        "missing": 0        <1>
+      }
     }
+  }
 }
 --------------------------------------------------
 // TEST[setup:exams]

+ 54 - 54
docs/reference/aggregations/metrics/geobounds-aggregation.asciidoc

@@ -10,13 +10,13 @@ Example:
 --------------------------------------------------
 PUT /museums
 {
-    "mappings": {
-        "properties": {
-            "location": {
-                "type": "geo_point"
-            }
-        }
+  "mappings": {
+    "properties": {
+      "location": {
+        "type": "geo_point"
+      }
     }
+  }
 }
 
 POST /museums/_bulk?refresh
@@ -35,17 +35,17 @@ POST /museums/_bulk?refresh
 
 POST /museums/_search?size=0
 {
-    "query" : {
-        "match" : { "name" : "musée" }
-    },
-    "aggs" : {
-        "viewport" : {
-            "geo_bounds" : {
-                "field" : "location", <1>
-                "wrap_longitude" : true <2>
-            }
-        }
+  "query": {
+    "match": { "name": "musée" }
+  },
+  "aggs": {
+    "viewport": {
+      "geo_bounds": {
+        "field": "location",    <1>
+        "wrap_longitude": true  <2>
+      }
     }
+  }
 }
 --------------------------------------------------
 
@@ -59,21 +59,21 @@ The response for the above aggregation:
 [source,console-result]
 --------------------------------------------------
 {
-    ...
-    "aggregations": {
-        "viewport": {
-            "bounds": {
-                "top_left": {
-                    "lat": 48.86111099738628,
-                    "lon": 2.3269999679178
-                },
-                "bottom_right": {
-                    "lat": 48.85999997612089,
-                    "lon": 2.3363889567553997
-                }
-            }
+  ...
+  "aggregations": {
+    "viewport": {
+      "bounds": {
+        "top_left": {
+          "lat": 48.86111099738628,
+          "lon": 2.3269999679178
+        },
+        "bottom_right": {
+          "lat": 48.85999997612089,
+          "lon": 2.3363889567553997
         }
+      }
     }
+  }
 }
 --------------------------------------------------
 // TESTRESPONSE[s/\.\.\./"took": $body.took,"_shards": $body._shards,"hits":$body.hits,"timed_out":false,/]
@@ -90,13 +90,13 @@ Example:
 --------------------------------------------------
 PUT /places
 {
-    "mappings": {
-        "properties": {
-            "geometry": {
-                "type": "geo_shape"
-            }
-        }
+  "mappings": {
+    "properties": {
+      "geometry": {
+        "type": "geo_shape"
+      }
     }
+  }
 }
 
 POST /places/_bulk?refresh
@@ -107,13 +107,13 @@ POST /places/_bulk?refresh
 
 POST /places/_search?size=0
 {
-    "aggs" : {
-        "viewport" : {
-            "geo_bounds" : {
-                "field" : "geometry"
-            }
-        }
+  "aggs": {
+    "viewport": {
+      "geo_bounds": {
+        "field": "geometry"
+      }
     }
+  }
 }
 --------------------------------------------------
 // TEST
@@ -121,21 +121,21 @@ POST /places/_search?size=0
 [source,console-result]
 --------------------------------------------------
 {
-    ...
-    "aggregations": {
-        "viewport": {
-            "bounds": {
-                "top_left": {
-                    "lat": 52.39420966710895,
-                    "lon": 4.912349972873926
-                },
-                "bottom_right": {
-                    "lat": 52.374080987647176,
-                    "lon": 4.969425117596984
-                }
-            }
+  ...
+  "aggregations": {
+    "viewport": {
+      "bounds": {
+        "top_left": {
+          "lat": 52.39420966710895,
+          "lon": 4.912349972873926
+        },
+        "bottom_right": {
+          "lat": 52.374080987647176,
+          "lon": 4.969425117596984
         }
+      }
     }
+  }
 }
 --------------------------------------------------
 // TESTRESPONSE[s/\.\.\./"took": $body.took,"_shards": $body._shards,"hits":$body.hits,"timed_out":false,/]

+ 90 - 90
docs/reference/aggregations/metrics/geocentroid-aggregation.asciidoc

@@ -9,13 +9,13 @@ Example:
 --------------------------------------------------
 PUT /museums
 {
-    "mappings": {
-        "properties": {
-            "location": {
-                "type": "geo_point"
-            }
-        }
+  "mappings": {
+    "properties": {
+      "location": {
+        "type": "geo_point"
+      }
     }
+  }
 }
 
 POST /museums/_bulk?refresh
@@ -34,13 +34,13 @@ POST /museums/_bulk?refresh
 
 POST /museums/_search?size=0
 {
-    "aggs" : {
-        "centroid" : {
-            "geo_centroid" : {
-                "field" : "location" <1>
-            }
-        }
+  "aggs": {
+    "centroid": {
+      "geo_centroid": {
+        "field": "location" <1>
+      }
     }
+  }
 }
 --------------------------------------------------
 
@@ -53,16 +53,16 @@ The response for the above aggregation:
 [source,console-result]
 --------------------------------------------------
 {
-    ...
-    "aggregations": {
-        "centroid": {
-            "location": {
-                "lat": 51.00982965203002,
-                "lon": 3.9662131341174245
-            },
-            "count": 6
-        }
+  ...
+  "aggregations": {
+    "centroid": {
+      "location": {
+        "lat": 51.00982965203002,
+        "lon": 3.9662131341174245
+      },
+      "count": 6
     }
+  }
 }
 --------------------------------------------------
 // TESTRESPONSE[s/\.\.\./"took": $body.took,"_shards": $body._shards,"hits":$body.hits,"timed_out":false,/]
@@ -75,16 +75,16 @@ Example:
 --------------------------------------------------
 POST /museums/_search?size=0
 {
-    "aggs" : {
-        "cities" : {
-            "terms" : { "field" : "city.keyword" },
-            "aggs" : {
-                "centroid" : {
-                    "geo_centroid" : { "field" : "location" }
-                }
-            }
+  "aggs": {
+    "cities": {
+      "terms": { "field": "city.keyword" },
+      "aggs": {
+        "centroid": {
+          "geo_centroid": { "field": "location" }
         }
+      }
     }
+  }
 }
 --------------------------------------------------
 // TEST[continued]
@@ -98,48 +98,48 @@ The response for the above aggregation:
 [source,console-result]
 --------------------------------------------------
 {
-    ...
-    "aggregations": {
-        "cities": {
-            "sum_other_doc_count": 0,
-            "doc_count_error_upper_bound": 0,
-            "buckets": [
-               {
-                   "key": "Amsterdam",
-                   "doc_count": 3,
-                   "centroid": {
-                      "location": {
-                         "lat": 52.371655656024814,
-                         "lon": 4.909563297405839
-                      },
-                      "count": 3
-                   }
-               },
-               {
-                   "key": "Paris",
-                   "doc_count": 2,
-                   "centroid": {
-                      "location": {
-                         "lat": 48.86055548675358,
-                         "lon": 2.3316944623366
-                      },
-                      "count": 2
-                   }
-                },
-                {
-                    "key": "Antwerp",
-                    "doc_count": 1,
-                    "centroid": {
-                       "location": {
-                          "lat": 51.22289997059852,
-                          "lon": 4.40519998781383
-                       },
-                       "count": 1
-                    }
-                 }
-            ]
+  ...
+  "aggregations": {
+    "cities": {
+      "sum_other_doc_count": 0,
+      "doc_count_error_upper_bound": 0,
+      "buckets": [
+        {
+          "key": "Amsterdam",
+          "doc_count": 3,
+          "centroid": {
+            "location": {
+              "lat": 52.371655656024814,
+              "lon": 4.909563297405839
+            },
+            "count": 3
+          }
+        },
+        {
+          "key": "Paris",
+          "doc_count": 2,
+          "centroid": {
+            "location": {
+              "lat": 48.86055548675358,
+              "lon": 2.3316944623366
+            },
+            "count": 2
+          }
+        },
+        {
+          "key": "Antwerp",
+          "doc_count": 1,
+          "centroid": {
+            "location": {
+              "lat": 51.22289997059852,
+              "lon": 4.40519998781383
+            },
+            "count": 1
+          }
         }
+      ]
     }
+  }
 }
 --------------------------------------------------
 // TESTRESPONSE[s/\.\.\./"took": $body.took,"_shards": $body._shards,"hits":$body.hits,"timed_out":false,/]
@@ -179,13 +179,13 @@ Example:
 --------------------------------------------------
 PUT /places
 {
-    "mappings": {
-        "properties": {
-            "geometry": {
-                "type": "geo_shape"
-            }
-        }
+  "mappings": {
+    "properties": {
+      "geometry": {
+        "type": "geo_shape"
+      }
     }
+  }
 }
 
 POST /places/_bulk?refresh
@@ -196,13 +196,13 @@ POST /places/_bulk?refresh
 
 POST /places/_search?size=0
 {
-    "aggs" : {
-        "centroid" : {
-            "geo_centroid" : {
-                "field" : "geometry"
-            }
-        }
+  "aggs": {
+    "centroid": {
+      "geo_centroid": {
+        "field": "geometry"
+      }
     }
+  }
 }
 --------------------------------------------------
 // TEST
@@ -210,16 +210,16 @@ POST /places/_search?size=0
 [source,console-result]
 --------------------------------------------------
 {
-    ...
-    "aggregations": {
-        "centroid": {
-            "location": {
-                "lat": 52.39296147599816,
-                "lon": 4.967404240742326
-            },
-            "count": 2
-        }
+  ...
+  "aggregations": {
+    "centroid": {
+      "location": {
+        "lat": 52.39296147599816,
+        "lon": 4.967404240742326
+      },
+      "count": 2
     }
+  }
 }
 --------------------------------------------------
 // TESTRESPONSE[s/\.\.\./"took": $body.took,"_shards": $body._shards,"hits":$body.hits,"timed_out":false,/]

+ 51 - 51
docs/reference/aggregations/metrics/max-aggregation.asciidoc

@@ -16,9 +16,9 @@ Computing the max price value across all documents
 --------------------------------------------------
 POST /sales/_search?size=0
 {
-    "aggs" : {
-        "max_price" : { "max" : { "field" : "price" } }
-    }
+  "aggs": {
+    "max_price": { "max": { "field": "price" } }
+  }
 }
 --------------------------------------------------
 // TEST[setup:sales]
@@ -28,12 +28,12 @@ Response:
 [source,console-result]
 --------------------------------------------------
 {
-    ...
-    "aggregations": {
-        "max_price": {
-            "value": 200.0
-        }
-    }
+  ...
+  "aggregations": {
+      "max_price": {
+          "value": 200.0
+      }
+  }
 }
 --------------------------------------------------
 // TESTRESPONSE[s/\.\.\./"took": $body.took,"timed_out": false,"_shards": $body._shards,"hits": $body.hits,/]
@@ -51,15 +51,15 @@ below computes the maximum price:
 --------------------------------------------------
 POST /sales/_search
 {
-    "aggs" : {
-        "max_price" : {
-            "max" : {
-                "script" : {
-                    "source" : "doc.price.value"
-                }
-            }
-        }
-    }
+  "aggs" : {
+      "max_price" : {
+          "max" : {
+              "script" : {
+                  "source" : "doc.price.value"
+              }
+          }
+      }
+  }
 }
 --------------------------------------------------
 // TEST[setup:sales]
@@ -71,18 +71,18 @@ and no script parameters. To use a stored script use the following syntax:
 --------------------------------------------------
 POST /sales/_search
 {
-    "aggs" : {
-        "max_price" : {
-            "max" : {
-                "script" : {
-                    "id": "my_script",
-                    "params": {
-                        "field": "price"
-                    }
-                }
-            }
-        }
-    }
+  "aggs" : {
+      "max_price" : {
+          "max" : {
+              "script" : {
+                  "id": "my_script",
+                  "params": {
+                      "field": "price"
+                  }
+              }
+          }
+      }
+  }
 }
 --------------------------------------------------
 // TEST[setup:sales,stored_example_script]
@@ -98,19 +98,19 @@ conversion rate to every value before it is aggregated:
 --------------------------------------------------
 POST /sales/_search
 {
-    "aggs" : {
-        "max_price_in_euros" : {
-            "max" : {
-                "field" : "price",
-                "script" : {
-                    "source" : "_value * params.conversion_rate",
-                    "params" : {
-                        "conversion_rate" : 1.2
-                    }
-                }
-            }
-        }
-    }
+  "aggs" : {
+      "max_price_in_euros" : {
+          "max" : {
+              "field" : "price",
+              "script" : {
+                  "source" : "_value * params.conversion_rate",
+                  "params" : {
+                      "conversion_rate" : 1.2
+                  }
+              }
+          }
+      }
+  }
 }
 --------------------------------------------------
 // TEST[setup:sales]
@@ -125,14 +125,14 @@ them as if they had a value.
 --------------------------------------------------
 POST /sales/_search
 {
-    "aggs" : {
-        "grade_max" : {
-            "max" : {
-                "field" : "grade",
-                "missing": 10 <1>
-            }
-        }
-    }
+  "aggs" : {
+      "grade_max" : {
+          "max" : {
+              "field" : "grade",
+              "missing": 10       <1>
+          }
+      }
+  }
 }
 --------------------------------------------------
 // TEST[setup:sales]

+ 43 - 43
docs/reference/aggregations/metrics/min-aggregation.asciidoc

@@ -16,9 +16,9 @@ Computing the min price value across all documents:
 --------------------------------------------------
 POST /sales/_search?size=0
 {
-    "aggs" : {
-        "min_price" : { "min" : { "field" : "price" } }
-    }
+  "aggs": {
+    "min_price": { "min": { "field": "price" } }
+  }
 }
 --------------------------------------------------
 // TEST[setup:sales]
@@ -28,13 +28,13 @@ Response:
 [source,console-result]
 --------------------------------------------------
 {
-    ...
+  ...
 
-    "aggregations": {
-        "min_price": {
-            "value": 10.0
-        }
+  "aggregations": {
+    "min_price": {
+      "value": 10.0
     }
+  }
 }
 --------------------------------------------------
 // TESTRESPONSE[s/\.\.\./"took": $body.took,"timed_out": false,"_shards": $body._shards,"hits": $body.hits,/]
@@ -52,15 +52,15 @@ below computes the minimum price:
 --------------------------------------------------
 POST /sales/_search
 {
-    "aggs" : {
-        "min_price" : {
-            "min" : {
-                "script" : {
-                    "source" : "doc.price.value"
-                }
-            }
+  "aggs": {
+    "min_price": {
+      "min": {
+        "script": {
+          "source": "doc.price.value"
         }
+      }
     }
+  }
 }
 --------------------------------------------------
 // TEST[setup:sales]
@@ -72,18 +72,18 @@ and no script parameters. To use a stored script use the following syntax:
 --------------------------------------------------
 POST /sales/_search
 {
-    "aggs" : {
-        "min_price" : {
-            "min" : {
-                "script" : {
-                    "id": "my_script",
-                    "params": {
-                        "field": "price"
-                    }
-                }
-            }
+  "aggs": {
+    "min_price": {
+      "min": {
+        "script": {
+          "id": "my_script",
+          "params": {
+            "field": "price"
+          }
         }
+      }
     }
+  }
 }
 --------------------------------------------------
 // TEST[setup:sales,stored_example_script]
@@ -99,19 +99,19 @@ conversion rate to every value before it is aggregated:
 --------------------------------------------------
 POST /sales/_search
 {
-    "aggs" : {
-        "min_price_in_euros" : {
-            "min" : {
-                "field" : "price",
-                "script" : {
-                    "source" : "_value * params.conversion_rate",
-                    "params" : {
-                        "conversion_rate" : 1.2
-                    }
-                }
-            }
+  "aggs": {
+    "min_price_in_euros": {
+      "min": {
+        "field": "price",
+        "script": {
+          "source": "_value * params.conversion_rate",
+          "params": {
+            "conversion_rate": 1.2
+          }
         }
+      }
     }
+  }
 }
 --------------------------------------------------
 // TEST[setup:sales]
@@ -126,14 +126,14 @@ them as if they had a value.
 --------------------------------------------------
 POST /sales/_search
 {
-    "aggs" : {
-        "grade_min" : {
-            "min" : {
-                "field" : "grade",
-                "missing": 10 <1>
-            }
-        }
+  "aggs": {
+    "grade_min": {
+      "min": {
+        "field": "grade",
+        "missing": 10 <1>
+      }
     }
+  }
 }
 --------------------------------------------------
 // TEST[setup:sales]

+ 121 - 121
docs/reference/aggregations/metrics/percentile-aggregation.asciidoc

@@ -28,14 +28,14 @@ Let's look at a range of percentiles representing load time:
 --------------------------------------------------
 GET latency/_search
 {
-    "size": 0,
-    "aggs" : {
-        "load_time_outlier" : {
-            "percentiles" : {
-                "field" : "load_time" <1>
-            }
-        }
+  "size": 0,
+  "aggs": {
+    "load_time_outlier": {
+      "percentiles": {
+        "field": "load_time" <1>
+      }
     }
+  }
 }
 --------------------------------------------------
 // TEST[setup:latency]
@@ -47,21 +47,21 @@ percentiles: `[ 1, 5, 25, 50, 75, 95, 99 ]`.  The response will look like this:
 [source,console-result]
 --------------------------------------------------
 {
-    ...
-
-   "aggregations": {
-      "load_time_outlier": {
-         "values" : {
-            "1.0": 5.0,
-            "5.0": 25.0,
-            "25.0": 165.0,
-            "50.0": 445.0,
-            "75.0": 725.0,
-            "95.0": 945.0,
-            "99.0": 985.0
-         }
+  ...
+
+ "aggregations": {
+    "load_time_outlier": {
+      "values": {
+        "1.0": 5.0,
+        "5.0": 25.0,
+        "25.0": 165.0,
+        "50.0": 445.0,
+        "75.0": 725.0,
+        "95.0": 945.0,
+        "99.0": 985.0
       }
-   }
+    }
+  }
 }
 --------------------------------------------------
 // TESTRESPONSE[s/\.\.\./"took": $body.took,"timed_out": false,"_shards": $body._shards,"hits": $body.hits,/]
@@ -79,15 +79,15 @@ must be a value between 0-100 inclusive):
 --------------------------------------------------
 GET latency/_search
 {
-    "size": 0,
-    "aggs" : {
-        "load_time_outlier" : {
-            "percentiles" : {
-                "field" : "load_time",
-                "percents" : [95, 99, 99.9] <1>
-            }
-        }
+  "size": 0,
+  "aggs": {
+    "load_time_outlier": {
+      "percentiles": {
+        "field": "load_time",
+        "percents": [ 95, 99, 99.9 ] <1>
+      }
     }
+  }
 }
 --------------------------------------------------
 // TEST[setup:latency]
@@ -101,15 +101,15 @@ By default the `keyed` flag is set to `true` which associates a unique string ke
 --------------------------------------------------
 GET latency/_search
 {
-    "size": 0,
-    "aggs": {
-        "load_time_outlier": {
-            "percentiles": {
-                "field": "load_time",
-                "keyed": false
-            }
-        }
+  "size": 0,
+  "aggs": {
+    "load_time_outlier": {
+      "percentiles": {
+        "field": "load_time",
+        "keyed": false
+      }
     }
+  }
 }
 --------------------------------------------------
 // TEST[setup:latency]
@@ -119,42 +119,42 @@ Response:
 [source,console-result]
 --------------------------------------------------
 {
-    ...
-
-    "aggregations": {
-        "load_time_outlier": {
-            "values": [
-                {
-                    "key": 1.0,
-                    "value": 5.0
-                },
-                {
-                    "key": 5.0,
-                    "value": 25.0
-                },
-                {
-                    "key": 25.0,
-                    "value": 165.0
-                },
-                {
-                    "key": 50.0,
-                    "value": 445.0
-                },
-                {
-                    "key": 75.0,
-                    "value": 725.0
-                },
-                {
-                    "key": 95.0,
-                    "value": 945.0
-                },
-                {
-                    "key": 99.0,
-                    "value": 985.0
-                }
-            ]
+  ...
+
+  "aggregations": {
+    "load_time_outlier": {
+      "values": [
+        {
+          "key": 1.0,
+          "value": 5.0
+        },
+        {
+          "key": 5.0,
+          "value": 25.0
+        },
+        {
+          "key": 25.0,
+          "value": 165.0
+        },
+        {
+          "key": 50.0,
+          "value": 445.0
+        },
+        {
+          "key": 75.0,
+          "value": 725.0
+        },
+        {
+          "key": 95.0,
+          "value": 945.0
+        },
+        {
+          "key": 99.0,
+          "value": 985.0
         }
+      ]
     }
+  }
 }
 --------------------------------------------------
 // TESTRESPONSE[s/\.\.\./"took": $body.took,"timed_out": false,"_shards": $body._shards,"hits": $body.hits,/]
@@ -169,20 +169,20 @@ a script to convert them on-the-fly:
 --------------------------------------------------
 GET latency/_search
 {
-    "size": 0,
-    "aggs" : {
-        "load_time_outlier" : {
-            "percentiles" : {
-                "script" : {
-                    "lang": "painless",
-                    "source": "doc['load_time'].value / params.timeUnit", <1>
-                    "params" : {
-                        "timeUnit" : 1000   <2>
-                    }
-                }
-            }
+  "size": 0,
+  "aggs": {
+    "load_time_outlier": {
+      "percentiles": {
+        "script": {
+          "lang": "painless",
+          "source": "doc['load_time'].value / params.timeUnit", <1>
+          "params": {
+            "timeUnit": 1000                                    <2>
+          }
         }
+      }
     }
+  }
 }
 --------------------------------------------------
 // TEST[setup:latency]
@@ -197,19 +197,19 @@ This will interpret the `script` parameter as an `inline` script with the `painl
 --------------------------------------------------
 GET latency/_search
 {
-    "size": 0,
-    "aggs" : {
-        "load_time_outlier" : {
-            "percentiles" : {
-                "script" : {
-                    "id": "my_script",
-                    "params": {
-                        "field": "load_time"
-                    }
-                }
-            }
+  "size": 0,
+  "aggs": {
+    "load_time_outlier": {
+      "percentiles": {
+        "script": {
+          "id": "my_script",
+          "params": {
+            "field": "load_time"
+          }
         }
+      }
     }
+  }
 }
 --------------------------------------------------
 // TEST[setup:latency,stored_example_script]
@@ -268,17 +268,17 @@ This balance can be controlled using a `compression` parameter:
 --------------------------------------------------
 GET latency/_search
 {
-    "size": 0,
-    "aggs" : {
-        "load_time_outlier" : {
-            "percentiles" : {
-                "field" : "load_time",
-                "tdigest": {
-                  "compression" : 200 <1>
-                }
-            }
+  "size": 0,
+  "aggs": {
+    "load_time_outlier": {
+      "percentiles": {
+        "field": "load_time",
+        "tdigest": {
+          "compression": 200    <1>
         }
+      }
     }
+  }
 }
 --------------------------------------------------
 // TEST[setup:latency]
@@ -320,18 +320,18 @@ The HDR Histogram can be used by specifying the `method` parameter in the reques
 --------------------------------------------------
 GET latency/_search
 {
-    "size": 0,
-    "aggs" : {
-        "load_time_outlier" : {
-            "percentiles" : {
-                "field" : "load_time",
-                "percents" : [95, 99, 99.9],
-                "hdr": { <1>
-                  "number_of_significant_value_digits" : 3 <2>
-                }
-            }
+  "size": 0,
+  "aggs": {
+    "load_time_outlier": {
+      "percentiles": {
+        "field": "load_time",
+        "percents": [ 95, 99, 99.9 ],
+        "hdr": {                                  <1>
+          "number_of_significant_value_digits": 3 <2>
         }
+      }
     }
+  }
 }
 --------------------------------------------------
 // TEST[setup:latency]
@@ -352,15 +352,15 @@ had a value.
 --------------------------------------------------
 GET latency/_search
 {
-    "size": 0,
-    "aggs" : {
-        "grade_percentiles" : {
-            "percentiles" : {
-                "field" : "grade",
-                "missing": 10 <1>
-            }
-        }
+  "size": 0,
+  "aggs": {
+    "grade_percentiles": {
+      "percentiles": {
+        "field": "grade",
+        "missing": 10       <1>
+      }
     }
+  }
 }
 --------------------------------------------------
 // TEST[setup:latency]

+ 84 - 84
docs/reference/aggregations/metrics/percentile-rank-aggregation.asciidoc

@@ -26,15 +26,15 @@ Let's look at a range of percentiles representing load time:
 --------------------------------------------------
 GET latency/_search
 {
-    "size": 0,
-    "aggs" : {
-        "load_time_ranks" : {
-            "percentile_ranks" : {
-                "field" : "load_time", <1>
-                "values" : [500, 600]
-            }
-        }
+  "size": 0,
+  "aggs": {
+    "load_time_ranks": {
+      "percentile_ranks": {
+        "field": "load_time",   <1>
+        "values": [ 500, 600 ]
+      }
     }
+  }
 }
 --------------------------------------------------
 // TEST[setup:latency]
@@ -46,16 +46,16 @@ The response will look like this:
 [source,console-result]
 --------------------------------------------------
 {
-    ...
-
-   "aggregations": {
-      "load_time_ranks": {
-         "values" : {
-            "500.0": 90.01,
-            "600.0": 100.0
-         }
+  ...
+
+ "aggregations": {
+    "load_time_ranks": {
+      "values": {
+        "500.0": 90.01,
+        "600.0": 100.0
       }
-   }
+    }
+  }
 }
 --------------------------------------------------
 // TESTRESPONSE[s/\.\.\./"took": $body.took,"timed_out": false,"_shards": $body._shards,"hits": $body.hits,/]
@@ -73,16 +73,16 @@ By default the `keyed` flag is set to `true` associates a unique string key with
 --------------------------------------------------
 GET latency/_search
 {
-    "size": 0,
-    "aggs": {
-        "load_time_ranks": {
-            "percentile_ranks": {
-                "field": "load_time",
-                "values": [500, 600],
-                "keyed": false
-            }
-        }
+  "size": 0,
+  "aggs": {
+    "load_time_ranks": {
+      "percentile_ranks": {
+        "field": "load_time",
+        "values": [ 500, 600 ],
+        "keyed": false
+      }
     }
+  }
 }
 --------------------------------------------------
 // TEST[setup:latency]
@@ -92,22 +92,22 @@ Response:
 [source,console-result]
 --------------------------------------------------
 {
-    ...
-
-    "aggregations": {
-        "load_time_ranks": {
-            "values": [
-                {
-                    "key": 500.0,
-                    "value": 90.01
-                },
-                {
-                    "key": 600.0,
-                    "value": 100.0
-                }
-            ]
+  ...
+
+  "aggregations": {
+    "load_time_ranks": {
+      "values": [
+        {
+          "key": 500.0,
+          "value": 90.01
+        },
+        {
+          "key": 600.0,
+          "value": 100.0
         }
+      ]
     }
+  }
 }
 --------------------------------------------------
 // TESTRESPONSE[s/\.\.\./"took": $body.took,"timed_out": false,"_shards": $body._shards,"hits": $body.hits,/]
@@ -125,21 +125,21 @@ a script to convert them on-the-fly:
 --------------------------------------------------
 GET latency/_search
 {
-    "size": 0,
-    "aggs" : {
-        "load_time_ranks" : {
-            "percentile_ranks" : {
-                "values" : [500, 600],
-                "script" : {
-                    "lang": "painless",
-                    "source": "doc['load_time'].value / params.timeUnit", <1>
-                    "params" : {
-                        "timeUnit" : 1000   <2>
-                    }
-                }
-            }
+  "size": 0,
+  "aggs": {
+    "load_time_ranks": {
+      "percentile_ranks": {
+        "values": [ 500, 600 ],
+        "script": {
+          "lang": "painless",
+          "source": "doc['load_time'].value / params.timeUnit", <1>
+          "params": {
+            "timeUnit": 1000                                    <2>
+          }
         }
+      }
     }
+  }
 }
 --------------------------------------------------
 // TEST[setup:latency]
@@ -154,20 +154,20 @@ This will interpret the `script` parameter as an `inline` script with the `painl
 --------------------------------------------------
 GET latency/_search
 {
-    "size": 0,
-    "aggs" : {
-        "load_time_ranks" : {
-            "percentile_ranks" : {
-                "values" : [500, 600],
-                "script" : {
-                    "id": "my_script",
-                    "params": {
-                        "field": "load_time"
-                    }
-                }
-            }
+  "size": 0,
+  "aggs": {
+    "load_time_ranks": {
+      "percentile_ranks": {
+        "values": [ 500, 600 ],
+        "script": {
+          "id": "my_script",
+          "params": {
+            "field": "load_time"
+          }
         }
+      }
     }
+  }
 }
 --------------------------------------------------
 // TEST[setup:latency,stored_example_script]
@@ -189,18 +189,18 @@ The HDR Histogram can be used by specifying the `hdr` object in the request:
 --------------------------------------------------
 GET latency/_search
 {
-    "size": 0,
-    "aggs" : {
-        "load_time_ranks" : {
-            "percentile_ranks" : {
-                "field" : "load_time",
-                "values" : [500, 600],
-                "hdr": { <1>
-                  "number_of_significant_value_digits" : 3 <2>
-                }
-            }
+  "size": 0,
+  "aggs": {
+    "load_time_ranks": {
+      "percentile_ranks": {
+        "field": "load_time",
+        "values": [ 500, 600 ],
+        "hdr": {                                  <1>
+          "number_of_significant_value_digits": 3 <2>
         }
+      }
     }
+  }
 }
 --------------------------------------------------
 // TEST[setup:latency]
@@ -221,16 +221,16 @@ had a value.
 --------------------------------------------------
 GET latency/_search
 {
-    "size": 0,
-    "aggs" : {
-        "load_time_ranks" : {
-            "percentile_ranks" : {
-                "field" : "load_time",
-                "values" : [500, 600],
-                "missing": 10 <1>
-            }
-        }
+  "size": 0,
+  "aggs": {
+    "load_time_ranks": {
+      "percentile_ranks": {
+        "field": "load_time",
+        "values": [ 500, 600 ],
+        "missing": 10           <1>
+      }
     }
+  }
 }
 --------------------------------------------------
 // TEST[setup:latency]

+ 51 - 51
docs/reference/aggregations/metrics/scripted-metric-aggregation.asciidoc

@@ -12,19 +12,19 @@ Example:
 --------------------------------------------------
 POST ledger/_search?size=0
 {
-    "query" : {
-        "match_all" : {}
-    },
-    "aggs": {
-        "profit": {
-            "scripted_metric": {
-                "init_script" : "state.transactions = []", <1>
-                "map_script" : "state.transactions.add(doc.type.value == 'sale' ? doc.amount.value : -1 * doc.amount.value)",
-                "combine_script" : "double profit = 0; for (t in state.transactions) { profit += t } return profit",
-                "reduce_script" : "double profit = 0; for (a in states) { profit += a } return profit"
-            }
-        }
+  "query": {
+    "match_all": {}
+  },
+  "aggs": {
+    "profit": {
+      "scripted_metric": {
+        "init_script": "state.transactions = []", <1>
+        "map_script": "state.transactions.add(doc.type.value == 'sale' ? doc.amount.value : -1 * doc.amount.value)",
+        "combine_script": "double profit = 0; for (t in state.transactions) { profit += t } return profit",
+        "reduce_script": "double profit = 0; for (a in states) { profit += a } return profit"
+      }
     }
+  }
 }
 --------------------------------------------------
 // TEST[setup:ledger]
@@ -38,13 +38,13 @@ The response for the above aggregation:
 [source,console-result]
 --------------------------------------------------
 {
-    "took": 218,
-    ...
-    "aggregations": {
-        "profit": {
-            "value": 240.0
-        }
-   }
+  "took": 218,
+  ...
+  "aggregations": {
+    "profit": {
+      "value": 240.0
+    }
+  }
 }
 --------------------------------------------------
 // TESTRESPONSE[s/"took": 218/"took": $body.took/]
@@ -56,27 +56,27 @@ The above example can also be specified using stored scripts as follows:
 --------------------------------------------------
 POST ledger/_search?size=0
 {
-    "aggs": {
-        "profit": {
-            "scripted_metric": {
-                "init_script" : {
-                    "id": "my_init_script"
-                },
-                "map_script" : {
-                    "id": "my_map_script"
-                },
-                "combine_script" : {
-                    "id": "my_combine_script"
-                },
-                "params": {
-                    "field": "amount" <1>
-                },
-                "reduce_script" : {
-                    "id": "my_reduce_script"
-                }
-            }
+  "aggs": {
+    "profit": {
+      "scripted_metric": {
+        "init_script": {
+          "id": "my_init_script"
+        },
+        "map_script": {
+          "id": "my_map_script"
+        },
+        "combine_script": {
+          "id": "my_combine_script"
+        },
+        "params": {
+          "field": "amount"           <1>
+        },
+        "reduce_script": {
+          "id": "my_reduce_script"
         }
+      }
     }
+  }
 }
 --------------------------------------------------
 // TEST[setup:ledger,stored_scripted_metric_script]
@@ -90,13 +90,13 @@ Verify this response as well but in a hidden block.
 [source,console-result]
 --------------------------------------------------
 {
-    "took": 218,
-    ...
-    "aggregations": {
-        "profit": {
-            "value": 240.0
-        }
-   }
+  "took": 218,
+  ...
+  "aggregations": {
+    "profit": {
+      "value": 240.0
+    }
+  }
 }
 --------------------------------------------------
 // TESTRESPONSE[s/"took": 218/"took": $body.took/]
@@ -250,13 +250,13 @@ produce the response:
 [source,js]
 --------------------------------------------------
 {
-    ...
+  ...
 
-    "aggregations": {
-        "profit": {
-            "value": 170
-        }
-   }
+  "aggregations": {
+    "profit": {
+      "value": 170
+    }
+  }
 }
 --------------------------------------------------
 // NOTCONSOLE

+ 51 - 51
docs/reference/aggregations/metrics/stats-aggregation.asciidoc

@@ -11,9 +11,9 @@ Assuming the data consists of documents representing exams grades (between 0 and
 --------------------------------------------------
 POST /exams/_search?size=0
 {
-    "aggs" : {
-        "grades_stats" : { "stats" : { "field" : "grade" } }
-    }
+  "aggs": {
+    "grades_stats": { "stats": { "field": "grade" } }
+  }
 }
 --------------------------------------------------
 // TEST[setup:exams]
@@ -24,17 +24,17 @@ The above aggregation computes the grades statistics over all documents. The agg
 [source,console-result]
 --------------------------------------------------
 {
-    ...
-
-    "aggregations": {
-        "grades_stats": {
-            "count": 2,
-            "min": 50.0,
-            "max": 100.0,
-            "avg": 75.0,
-            "sum": 150.0
-        }
+  ...
+
+  "aggregations": {
+    "grades_stats": {
+      "count": 2,
+      "min": 50.0,
+      "max": 100.0,
+      "avg": 75.0,
+      "sum": 150.0
     }
+  }
 }
 --------------------------------------------------
 // TESTRESPONSE[s/\.\.\./"took": $body.took,"timed_out": false,"_shards": $body._shards,"hits": $body.hits,/]
@@ -49,16 +49,16 @@ Computing the grades stats based on a script:
 --------------------------------------------------
 POST /exams/_search?size=0
 {
-    "aggs" : {
-        "grades_stats" : {
-             "stats" : {
-                 "script" : {
-                     "lang": "painless",
-                     "source": "doc['grade'].value"
-                 }
-             }
-         }
+  "aggs": {
+    "grades_stats": {
+      "stats": {
+        "script": {
+          "lang": "painless",
+          "source": "doc['grade'].value"
+        }
+      }
     }
+  }
 }
 --------------------------------------------------
 // TEST[setup:exams]
@@ -69,18 +69,18 @@ This will interpret the `script` parameter as an `inline` script with the `painl
 --------------------------------------------------
 POST /exams/_search?size=0
 {
-    "aggs" : {
-        "grades_stats" : {
-            "stats" : { 
-                "script" : {
-                    "id": "my_script",
-                    "params" : {
-                        "field" : "grade"
-                    }
-                }
-            }
+  "aggs": {
+    "grades_stats": {
+      "stats": {
+        "script": {
+          "id": "my_script",
+          "params": {
+            "field": "grade"
+          }
         }
+      }
     }
+  }
 }
 --------------------------------------------------
 // TEST[setup:exams,stored_example_script]
@@ -93,20 +93,20 @@ It turned out that the exam was way above the level of the students and a grade
 --------------------------------------------------
 POST /exams/_search?size=0
 {
-    "aggs" : {
-        "grades_stats" : {
-            "stats" : {
-                "field" : "grade",
-                "script" : {
-                    "lang": "painless",
-                    "source": "_value * params.correction",
-                    "params" : {
-                        "correction" : 1.2
-                    }
-                }
-            }
+  "aggs": {
+    "grades_stats": {
+      "stats": {
+        "field": "grade",
+        "script": {
+          "lang": "painless",
+          "source": "_value * params.correction",
+          "params": {
+            "correction": 1.2
+          }
         }
+      }
     }
+  }
 }
 --------------------------------------------------
 // TEST[setup:exams]
@@ -121,14 +121,14 @@ had a value.
 --------------------------------------------------
 POST /exams/_search?size=0
 {
-    "aggs" : {
-        "grades_stats" : {
-            "stats" : {
-                "field" : "grade",
-                "missing": 0 <1>
-            }
-        }
+  "aggs": {
+    "grades_stats": {
+      "stats": {
+        "field": "grade",
+        "missing": 0      <1>
+      }
     }
+  }
 }
 --------------------------------------------------
 // TEST[setup:exams]

+ 93 - 93
docs/reference/aggregations/metrics/string-stats-aggregation.asciidoc

@@ -25,9 +25,9 @@ Assuming the data consists of a twitter messages:
 --------------------------------------------------
 POST /twitter/_search?size=0
 {
-    "aggs" : {
-        "message_stats" : { "string_stats" : { "field" : "message.keyword" } }
-    }
+  "aggs": {
+    "message_stats": { "string_stats": { "field": "message.keyword" } }
+  }
 }
 --------------------------------------------------
 // TEST[setup:twitter]
@@ -39,17 +39,17 @@ The above will return the following:
 [source,console-result]
 --------------------------------------------------
 {
-    ...
-
-    "aggregations": {
-        "message_stats" : {
-            "count" : 5,
-            "min_length" : 24,
-            "max_length" : 30,
-            "avg_length" : 28.8,
-            "entropy" : 3.94617750050791
-        }
+  ...
+
+  "aggregations": {
+    "message_stats": {
+      "count": 5,
+      "min_length": 24,
+      "max_length": 30,
+      "avg_length": 28.8,
+      "entropy": 3.94617750050791
     }
+  }
 }
 --------------------------------------------------
 // TESTRESPONSE[s/\.\.\./"took": $body.took,"timed_out": false,"_shards": $body._shards,"hits": $body.hits,/]
@@ -66,14 +66,14 @@ by the aggregation. To view the probability distribution for all characters, we
 --------------------------------------------------
 POST /twitter/_search?size=0
 {
-    "aggs" : {
-        "message_stats" : {
-            "string_stats" : {
-                "field" : "message.keyword",
-                "show_distribution": true  <1>
-            }
-        }
+  "aggs": {
+    "message_stats": {
+      "string_stats": {
+        "field": "message.keyword",
+        "show_distribution": true  <1>
+      }
     }
+  }
 }
 --------------------------------------------------
 // TEST[setup:twitter]
@@ -83,42 +83,42 @@ POST /twitter/_search?size=0
 [source,console-result]
 --------------------------------------------------
 {
-    ...
-
-    "aggregations": {
-        "message_stats" : {
-            "count" : 5,
-            "min_length" : 24,
-            "max_length" : 30,
-            "avg_length" : 28.8,
-            "entropy" : 3.94617750050791,
-            "distribution" : {
-                " " : 0.1527777777777778,
-                "e" : 0.14583333333333334,
-                "s" : 0.09722222222222222,
-                "m" : 0.08333333333333333,
-                "t" : 0.0763888888888889,
-                "h" : 0.0625,
-                "a" : 0.041666666666666664,
-                "i" : 0.041666666666666664,
-                "r" : 0.041666666666666664,
-                "g" : 0.034722222222222224,
-                "n" : 0.034722222222222224,
-                "o" : 0.034722222222222224,
-                "u" : 0.034722222222222224,
-                "b" : 0.027777777777777776,
-                "w" : 0.027777777777777776,
-                "c" : 0.013888888888888888,
-                "E" : 0.006944444444444444,
-                "l" : 0.006944444444444444,
-                "1" : 0.006944444444444444,
-                "2" : 0.006944444444444444,
-                "3" : 0.006944444444444444,
-                "4" : 0.006944444444444444,
-                "y" : 0.006944444444444444
-            }
-        }
+  ...
+
+  "aggregations": {
+    "message_stats": {
+      "count": 5,
+      "min_length": 24,
+      "max_length": 30,
+      "avg_length": 28.8,
+      "entropy": 3.94617750050791,
+      "distribution": {
+        " ": 0.1527777777777778,
+        "e": 0.14583333333333334,
+        "s": 0.09722222222222222,
+        "m": 0.08333333333333333,
+        "t": 0.0763888888888889,
+        "h": 0.0625,
+        "a": 0.041666666666666664,
+        "i": 0.041666666666666664,
+        "r": 0.041666666666666664,
+        "g": 0.034722222222222224,
+        "n": 0.034722222222222224,
+        "o": 0.034722222222222224,
+        "u": 0.034722222222222224,
+        "b": 0.027777777777777776,
+        "w": 0.027777777777777776,
+        "c": 0.013888888888888888,
+        "E": 0.006944444444444444,
+        "l": 0.006944444444444444,
+        "1": 0.006944444444444444,
+        "2": 0.006944444444444444,
+        "3": 0.006944444444444444,
+        "4": 0.006944444444444444,
+        "y": 0.006944444444444444
+      }
     }
+  }
 }
 --------------------------------------------------
 // TESTRESPONSE[s/\.\.\./"took": $body.took,"timed_out": false,"_shards": $body._shards,"hits": $body.hits,/]
@@ -133,16 +133,16 @@ Computing the message string stats based on a script:
 --------------------------------------------------
 POST /twitter/_search?size=0
 {
-    "aggs" : {
-        "message_stats" : {
-             "string_stats" : {
-                 "script" : {
-                     "lang": "painless",
-                     "source": "doc['message.keyword'].value"
-                 }
-             }
-         }
+  "aggs": {
+    "message_stats": {
+      "string_stats": {
+        "script": {
+          "lang": "painless",
+          "source": "doc['message.keyword'].value"
+        }
+      }
     }
+  }
 }
 --------------------------------------------------
 // TEST[setup:twitter]
@@ -154,18 +154,18 @@ To use a stored script use the following syntax:
 --------------------------------------------------
 POST /twitter/_search?size=0
 {
-    "aggs" : {
-        "message_stats" : {
-            "string_stats" : {
-                "script" : {
-                    "id": "my_script",
-                    "params" : {
-                        "field" : "message.keyword"
-                    }
-                }
-            }
+  "aggs": {
+    "message_stats": {
+      "string_stats": {
+        "script": {
+          "id": "my_script",
+          "params": {
+            "field": "message.keyword"
+          }
         }
+      }
     }
+  }
 }
 --------------------------------------------------
 // TEST[setup:twitter,stored_example_script]
@@ -178,20 +178,20 @@ We can use a value script to modify the message (eg we can add a prefix) and com
 --------------------------------------------------
 POST /twitter/_search?size=0
 {
-    "aggs" : {
-        "message_stats" : {
-            "string_stats" : {
-                "field" : "message.keyword",
-                "script" : {
-                    "lang": "painless",
-                    "source": "params.prefix + _value",
-                    "params" : {
-                        "prefix" : "Message: "
-                    }
-                }
-            }
+  "aggs": {
+    "message_stats": {
+      "string_stats": {
+        "field": "message.keyword",
+        "script": {
+          "lang": "painless",
+          "source": "params.prefix + _value",
+          "params": {
+            "prefix": "Message: "
+          }
         }
+      }
     }
+  }
 }
 --------------------------------------------------
 // TEST[setup:twitter]
@@ -205,14 +205,14 @@ By default they will be ignored but it is also possible to treat them as if they
 --------------------------------------------------
 POST /twitter/_search?size=0
 {
-    "aggs" : {
-        "message_stats" : {
-            "string_stats" : {
-                "field" : "message.keyword",
-                "missing": "[empty message]" <1>
-            }
-        }
+  "aggs": {
+    "message_stats": {
+      "string_stats": {
+        "field": "message.keyword",
+        "missing": "[empty message]" <1>
+      }
     }
+  }
 }
 --------------------------------------------------
 // TEST[setup:twitter]

+ 82 - 82
docs/reference/aggregations/metrics/sum-aggregation.asciidoc

@@ -12,16 +12,16 @@ the sale price of all hats with:
 --------------------------------------------------
 POST /sales/_search?size=0
 {
-    "query" : {
-        "constant_score" : {
-            "filter" : {
-                "match" : { "type" : "hat" }
-            }
-        }
-    },
-    "aggs" : {
-        "hat_prices" : { "sum" : { "field" : "price" } }
+  "query": {
+    "constant_score": {
+      "filter": {
+        "match": { "type": "hat" }
+      }
     }
+  },
+  "aggs": {
+    "hat_prices": { "sum": { "field": "price" } }
+  }
 }
 --------------------------------------------------
 // TEST[setup:sales]
@@ -31,12 +31,12 @@ Resulting in:
 [source,console-result]
 --------------------------------------------------
 {
-    ...
-    "aggregations" : {
-        "hat_prices" : {
-           "value" : 450.0
-        }
+  ...
+  "aggregations": {
+    "hat_prices": {
+      "value": 450.0
     }
+  }
 }
 --------------------------------------------------
 // TESTRESPONSE[s/\.\.\./"took": $body.took,"timed_out": false,"_shards": $body._shards,"hits": $body.hits,/]
@@ -51,22 +51,22 @@ We could also use a script to fetch the sales price:
 --------------------------------------------------
 POST /sales/_search?size=0
 {
-    "query" : {
-        "constant_score" : {
-            "filter" : {
-                "match" : { "type" : "hat" }
-            }
-        }
-    },
-    "aggs" : {
-        "hat_prices" : {
-            "sum" : {
-                "script" : {
-                   "source": "doc.price.value"
-                }
-            }
+  "query": {
+    "constant_score": {
+      "filter": {
+        "match": { "type": "hat" }
+      }
+    }
+  },
+  "aggs": {
+    "hat_prices": {
+      "sum": {
+        "script": {
+          "source": "doc.price.value"
         }
+      }
     }
+  }
 }
 --------------------------------------------------
 // TEST[setup:sales]
@@ -77,25 +77,25 @@ This will interpret the `script` parameter as an `inline` script with the `painl
 --------------------------------------------------
 POST /sales/_search?size=0
 {
-    "query" : {
-        "constant_score" : {
-            "filter" : {
-                "match" : { "type" : "hat" }
-            }
-        }
-    },
-    "aggs" : {
-        "hat_prices" : {
-            "sum" : {
-                "script" : {
-                    "id": "my_script",
-                    "params" : {
-                        "field" : "price"
-                    }
-                }
-            }
+  "query": {
+    "constant_score": {
+      "filter": {
+        "match": { "type": "hat" }
+      }
+    }
+  },
+  "aggs": {
+    "hat_prices": {
+      "sum": {
+        "script": {
+          "id": "my_script",
+          "params": {
+            "field": "price"
+          }
         }
+      }
     }
+  }
 }
 --------------------------------------------------
 // TEST[setup:sales,stored_example_script]
@@ -109,23 +109,23 @@ For example, this will sum the square of the prices for all hats:
 --------------------------------------------------
 POST /sales/_search?size=0
 {
-    "query" : {
-        "constant_score" : {
-            "filter" : {
-                "match" : { "type" : "hat" }
-            }
-        }
-    },
-    "aggs" : {
-        "square_hats" : {
-            "sum" : {
-                "field" : "price",
-                "script" : {
-                    "source": "_value * _value"
-                }
-            }
+  "query": {
+    "constant_score": {
+      "filter": {
+        "match": { "type": "hat" }
+      }
+    }
+  },
+  "aggs": {
+    "square_hats": {
+      "sum": {
+        "field": "price",
+        "script": {
+          "source": "_value * _value"
         }
+      }
     }
+  }
 }
 --------------------------------------------------
 // TEST[setup:sales]
@@ -141,21 +141,21 @@ all hat sales without a price as being `100`.
 --------------------------------------------------
 POST /sales/_search?size=0
 {
-    "query" : {
-        "constant_score" : {
-            "filter" : {
-                "match" : { "type" : "hat" }
-            }
-        }
-    },
-    "aggs" : {
-        "hat_prices" : {
-            "sum" : {
-                "field" : "price",
-                "missing": 100 <1>
-            }
-        }
+  "query": {
+    "constant_score": {
+      "filter": {
+        "match": { "type": "hat" }
+      }
     }
+  },
+  "aggs": {
+    "hat_prices": {
+      "sum": {
+        "field": "price",
+        "missing": 100 <1>
+      }
+    }
+  }
 }
 --------------------------------------------------
 // TEST[setup:sales]
@@ -190,9 +190,9 @@ PUT metrics_index/_doc/2
 
 POST /metrics_index/_search?size=0
 {
-    "aggs" : {
-        "total_latency" : { "sum" : { "field" : "latency_histo" } }
-    }
+  "aggs" : {
+    "total_latency" : { "sum" : { "field" : "latency_histo" } }
+  }
 }
 --------------------------------------------------
 
@@ -202,12 +202,12 @@ in the `counts` array <2>. Eventually, it will add all values for all histograms
 [source,console-result]
 --------------------------------------------------
 {
-    ...
-    "aggregations" : {
-        "total_latency" : {
-           "value" : 28.8
-        }
+  ...
+  "aggregations": {
+    "total_latency": {
+      "value": 28.8
     }
+  }
 }
 --------------------------------------------------
 // TESTRESPONSE[skip:test not setup]

+ 66 - 66
docs/reference/aggregations/metrics/t-test-aggregation.asciidoc

@@ -14,11 +14,11 @@ A `t_test` aggregation looks like this in isolation:
 [source,js]
 --------------------------------------------------
 {
-    "t_test": {
-        "a": "value_before",
-        "b": "value_after",
-        "type": "paired"
-    }
+  "t_test": {
+    "a": "value_before",
+    "b": "value_after",
+    "type": "paired"
+  }
 }
 --------------------------------------------------
 // NOTCONSOLE
@@ -30,16 +30,16 @@ the node start up time in a meaningful way.
 --------------------------------------------------
 GET node_upgrade/_search
 {
-    "size": 0,
-    "aggs" : {
-        "startup_time_ttest" : {
-            "t_test" : {
-                "a" : {"field": "startup_time_before"}, <1>
-                "b" : {"field": "startup_time_after"}, <2>
-                "type": "paired" <3>
-            }
-        }
+  "size": 0,
+  "aggs": {
+    "startup_time_ttest": {
+      "t_test": {
+        "a": { "field": "startup_time_before" },  <1>
+        "b": { "field": "startup_time_after" },   <2>
+        "type": "paired"                          <3>
+      }
     }
+  }
 }
 --------------------------------------------------
 // TEST[setup:node_upgrade]
@@ -54,13 +54,13 @@ population means). Smaller p-value means the null hypothesis is more likely to b
 [source,console-result]
 --------------------------------------------------
 {
-    ...
+  ...
 
-   "aggregations": {
-      "startup_time_ttest": {
-         "value":  0.1914368843365979 <1>
-      }
-   }
+ "aggregations": {
+    "startup_time_ttest": {
+      "value": 0.1914368843365979 <1>
+    }
+  }
 }
 --------------------------------------------------
 // TESTRESPONSE[s/\.\.\./"took": $body.took,"timed_out": false,"_shards": $body._shards,"hits": $body.hits,/]
@@ -84,30 +84,30 @@ nodes using terms filters on the group name field:
 --------------------------------------------------
 GET node_upgrade/_search
 {
-    "size" : 0,
-    "aggs" : {
-        "startup_time_ttest" : {
-            "t_test" : {
-                "a" : {
-                    "field" : "startup_time_before", <1>
-                    "filter" : {
-                        "term" : {
-                            "group" : "A"  <2>
-                        }
-                    }
-                },
-                "b" : {
-                    "field" : "startup_time_before", <3>
-                    "filter" : {
-                        "term" : {
-                            "group" : "B" <4>
-                        }
-                    }
-                },
-                "type" : "heteroscedastic" <5>
+  "size": 0,
+  "aggs": {
+    "startup_time_ttest": {
+      "t_test": {
+        "a": {
+          "field": "startup_time_before",         <1>
+          "filter": {
+            "term": {
+              "group": "A"                        <2>
             }
-        }
+          }
+        },
+        "b": {
+          "field": "startup_time_before",         <3>
+          "filter": {
+            "term": {
+              "group": "B"                        <4>
+            }
+          }
+        },
+        "type": "heteroscedastic"                 <5>
+      }
     }
+  }
 }
 --------------------------------------------------
 // TEST[setup:node_upgrade]
@@ -121,13 +121,13 @@ GET node_upgrade/_search
 [source,console-result]
 --------------------------------------------------
 {
-    ...
+  ...
 
-   "aggregations": {
-      "startup_time_ttest": {
-         "value":  0.2981858007281437 <1>
-      }
-   }
+ "aggregations": {
+    "startup_time_ttest": {
+      "value": 0.2981858007281437 <1>
+    }
+  }
 }
 --------------------------------------------------
 // TESTRESPONSE[s/\.\.\./"took": $body.took,"timed_out": false,"_shards": $body._shards,"hits": $body.hits,/]
@@ -146,26 +146,26 @@ a script to recalculate them on-the-fly:
 --------------------------------------------------
 GET node_upgrade/_search
 {
-    "size": 0,
-    "aggs" : {
-        "startup_time_ttest" : {
-            "t_test" : {
-                "a": {
-                    "script" : {
-                        "lang": "painless",
-                        "source": "doc['startup_time_before'].value - params.adjustment", <1>
-                        "params" : {
-                            "adjustment" : 10   <2>
-                        }
-                    }
-                },
-                "b": {
-                    "field": "startup_time_after" <3>
-                },
-                "type": "paired"
+  "size": 0,
+  "aggs": {
+    "startup_time_ttest": {
+      "t_test": {
+        "a": {
+          "script": {
+            "lang": "painless",
+            "source": "doc['startup_time_before'].value - params.adjustment", <1>
+            "params": {
+              "adjustment": 10                                                <2>
             }
-        }
+          }
+        },
+        "b": {
+          "field": "startup_time_after"                                       <3>
+        },
+        "type": "paired"
+      }
     }
+  }
 }
 --------------------------------------------------
 // TEST[setup:node_upgrade]

+ 58 - 58
docs/reference/aggregations/metrics/tophits-aggregation.asciidoc

@@ -39,31 +39,31 @@ For each sale only the date and price fields are being included in the source.
 --------------------------------------------------
 POST /sales/_search?size=0
 {
-    "aggs": {
-        "top_tags": {
-            "terms": {
-                "field": "type",
-                "size": 3
-            },
-            "aggs": {
-                "top_sales_hits": {
-                    "top_hits": {
-                        "sort": [
-                            {
-                                "date": {
-                                    "order": "desc"
-                                }
-                            }
-                        ],
-                        "_source": {
-                            "includes": [ "date", "price" ]
-                        },
-                        "size" : 1
-                    }
+  "aggs": {
+    "top_tags": {
+      "terms": {
+        "field": "type",
+        "size": 3
+      },
+      "aggs": {
+        "top_sales_hits": {
+          "top_hits": {
+            "sort": [
+              {
+                "date": {
+                  "order": "desc"
                 }
-            }
+              }
+            ],
+            "_source": {
+              "includes": [ "date", "price" ]
+            },
+            "size": 1
+          }
         }
+      }
     }
+  }
 }
 --------------------------------------------------
 // TEST[setup:sales]
@@ -241,18 +241,18 @@ Let's see how it works with a real sample. Considering the following mapping:
 --------------------------------------------------
 PUT /sales
 {
-    "mappings": {
-        "properties" : {
-            "tags" : { "type" : "keyword" },
-            "comments" : { <1>
-                "type" : "nested",
-                "properties" : {
-                    "username" : { "type" : "keyword" },
-                    "comment" : { "type" : "text" }
-                }
-            }
+  "mappings": {
+    "properties": {
+      "tags": { "type": "keyword" },
+      "comments": {                           <1>
+        "type": "nested",
+        "properties": {
+          "username": { "type": "keyword" },
+          "comment": { "type": "text" }
         }
+      }
     }
+  }
 }
 --------------------------------------------------
 
@@ -264,12 +264,12 @@ And some documents:
 --------------------------------------------------
 PUT /sales/_doc/1?refresh
 {
-    "tags": ["car", "auto"],
-    "comments": [
-        {"username": "baddriver007", "comment": "This car could have better brakes"},
-        {"username": "dr_who", "comment": "Where's the autopilot? Can't find it"},
-        {"username": "ilovemotorbikes", "comment": "This car has two extra wheels"}
-    ]
+  "tags": [ "car", "auto" ],
+  "comments": [
+    { "username": "baddriver007", "comment": "This car could have better brakes" },
+    { "username": "dr_who", "comment": "Where's the autopilot? Can't find it" },
+    { "username": "ilovemotorbikes", "comment": "This car has two extra wheels" }
+  ]
 }
 --------------------------------------------------
 // TEST[continued]
@@ -280,29 +280,29 @@ It's now possible to execute the following `top_hits` aggregation (wrapped in a
 --------------------------------------------------
 POST /sales/_search
 {
-    "query": {
-        "term": { "tags": "car" }
-    },
-    "aggs": {
-        "by_sale": {
-            "nested" : {
-                "path" : "comments"
-            },
-            "aggs": {
-                "by_user": {
-                    "terms": {
-                        "field": "comments.username",
-                        "size": 1
-                    },
-                    "aggs": {
-                        "by_nested": {
-                            "top_hits":{}
-                        }
-                    }
-                }
+  "query": {
+    "term": { "tags": "car" }
+  },
+  "aggs": {
+    "by_sale": {
+      "nested": {
+        "path": "comments"
+      },
+      "aggs": {
+        "by_user": {
+          "terms": {
+            "field": "comments.username",
+            "size": 1
+          },
+          "aggs": {
+            "by_nested": {
+              "top_hits": {}
             }
+          }
         }
+      }
     }
+  }
 }
 --------------------------------------------------
 // TEST[continued]

+ 34 - 34
docs/reference/aggregations/metrics/valuecount-aggregation.asciidoc

@@ -13,9 +13,9 @@ identical values for a single document), each value will be counted individually
 --------------------------------------------------
 POST /sales/_search?size=0
 {
-    "aggs" : {
-        "types_count" : { "value_count" : { "field" : "type" } }
-    }
+  "aggs" : {
+    "types_count" : { "value_count" : { "field" : "type" } }
+  }
 }
 --------------------------------------------------
 // TEST[setup:sales]
@@ -25,12 +25,12 @@ Response:
 [source,console-result]
 --------------------------------------------------
 {
-    ...
-    "aggregations": {
-        "types_count": {
-            "value": 7
-        }
+  ...
+  "aggregations": {
+    "types_count": {
+      "value": 7
     }
+  }
 }
 --------------------------------------------------
 // TESTRESPONSE[s/\.\.\./"took": $body.took,"timed_out": false,"_shards": $body._shards,"hits": $body.hits,/]
@@ -46,15 +46,15 @@ Counting the values generated by a script:
 --------------------------------------------------
 POST /sales/_search?size=0
 {
-    "aggs" : {
-        "type_count" : {
-            "value_count" : {
-                "script" : {
-                    "source" : "doc['type'].value"
-                }
-            }
+  "aggs": {
+    "type_count": {
+      "value_count": {
+        "script": {
+          "source": "doc['type'].value"
         }
+      }
     }
+  }
 }
 --------------------------------------------------
 // TEST[setup:sales]
@@ -65,18 +65,18 @@ This will interpret the `script` parameter as an `inline` script with the `painl
 --------------------------------------------------
 POST /sales/_search?size=0
 {
-    "aggs" : {
-        "types_count" : {
-            "value_count" : {
-                "script" : {
-                    "id": "my_script",
-                    "params" : {
-                        "field" : "type"
-                    }
-                }
-            }
+  "aggs": {
+    "types_count": {
+      "value_count": {
+        "script": {
+          "id": "my_script",
+          "params": {
+            "field": "type"
+          }
         }
+      }
     }
+  }
 }
 --------------------------------------------------
 // TEST[setup:sales,stored_example_script]
@@ -114,11 +114,11 @@ PUT metrics_index/_doc/2
 
 POST /metrics_index/_search?size=0
 {
-    "aggs" : {
-        "total_requests" : {
-            "value_count" : { "field" : "latency_histo" }
-        }
+  "aggs": {
+    "total_requests": {
+      "value_count": { "field": "latency_histo" }
     }
+  }
 }
 --------------------------------------------------
 
@@ -128,12 +128,12 @@ Eventually, it will add all values for all histograms and return the following r
 [source,console-result]
 --------------------------------------------------
 {
-    ...
-    "aggregations" : {
-        "total_requests" : {
-           "value" : 97
-        }
+  ...
+  "aggregations": {
+    "total_requests": {
+      "value": 97
     }
+  }
 }
 --------------------------------------------------
 // TESTRESPONSE[skip:test not setup]

+ 58 - 58
docs/reference/aggregations/metrics/weighted-avg-aggregation.asciidoc

@@ -55,19 +55,19 @@ we can calculate the weighted average using:
 --------------------------------------------------
 POST /exams/_search
 {
-    "size": 0,
-    "aggs" : {
-        "weighted_grade": {
-            "weighted_avg": {
-                "value": {
-                    "field": "grade"
-                },
-                "weight": {
-                    "field": "weight"
-                }
-            }
+  "size": 0,
+  "aggs": {
+    "weighted_grade": {
+      "weighted_avg": {
+        "value": {
+          "field": "grade"
+        },
+        "weight": {
+          "field": "weight"
         }
+      }
     }
+  }
 }
 --------------------------------------------------
 // TEST[setup:exams]
@@ -77,12 +77,12 @@ Which yields a response like:
 [source,console-result]
 --------------------------------------------------
 {
-    ...
-    "aggregations": {
-        "weighted_grade": {
-            "value": 70.0
-        }
+  ...
+  "aggregations": {
+    "weighted_grade": {
+      "value": 70.0
     }
+  }
 }
 --------------------------------------------------
 // TESTRESPONSE[s/\.\.\./"took": $body.took,"timed_out": false,"_shards": $body._shards,"hits": $body.hits,/]
@@ -101,25 +101,25 @@ This example show how a single document with multiple values will be averaged wi
 --------------------------------------------------
 POST /exams/_doc?refresh
 {
-    "grade": [1, 2, 3],
-    "weight": 2
+  "grade": [1, 2, 3],
+  "weight": 2
 }
 
 POST /exams/_search
 {
-    "size": 0,
-    "aggs" : {
-        "weighted_grade": {
-            "weighted_avg": {
-                "value": {
-                    "field": "grade"
-                },
-                "weight": {
-                    "field": "weight"
-                }
-            }
+  "size": 0,
+  "aggs": {
+    "weighted_grade": {
+      "weighted_avg": {
+        "value": {
+          "field": "grade"
+        },
+        "weight": {
+          "field": "weight"
         }
+      }
     }
+  }
 }
 --------------------------------------------------
 // TEST
@@ -129,12 +129,12 @@ The three values (`1`, `2`, and `3`) will be included as independent values, all
 [source,console-result]
 --------------------------------------------------
 {
-    ...
-    "aggregations": {
-        "weighted_grade": {
-            "value": 2.0
-        }
+  ...
+  "aggregations": {
+    "weighted_grade": {
+      "value": 2.0
     }
+  }
 }
 --------------------------------------------------
 // TESTRESPONSE[s/\.\.\./"took": $body.took,"timed_out": false,"_shards": $body._shards,"hits": $body.hits,/]
@@ -151,19 +151,19 @@ will add one to the grade and weight in the document using a script:
 --------------------------------------------------
 POST /exams/_search
 {
-    "size": 0,
-    "aggs" : {
-        "weighted_grade": {
-            "weighted_avg": {
-                "value": {
-                    "script": "doc.grade.value + 1"
-                },
-                "weight": {
-                    "script": "doc.weight.value + 1"
-                }
-            }
+  "size": 0,
+  "aggs": {
+    "weighted_grade": {
+      "weighted_avg": {
+        "value": {
+          "script": "doc.grade.value + 1"
+        },
+        "weight": {
+          "script": "doc.weight.value + 1"
         }
+      }
     }
+  }
 }
 --------------------------------------------------
 // TEST[setup:exams]
@@ -183,21 +183,21 @@ Both of these defaults can be overridden with the `missing` parameter:
 --------------------------------------------------
 POST /exams/_search
 {
-    "size": 0,
-    "aggs" : {
-        "weighted_grade": {
-            "weighted_avg": {
-                "value": {
-                    "field": "grade",
-                    "missing": 2
-                },
-                "weight": {
-                    "field": "weight",
-                    "missing": 3
-                }
-            }
+  "size": 0,
+  "aggs": {
+    "weighted_grade": {
+      "weighted_avg": {
+        "value": {
+          "field": "grade",
+          "missing": 2
+        },
+        "weight": {
+          "field": "weight",
+          "missing": 3
         }
+      }
     }
+  }
 }
 --------------------------------------------------
 // TEST[setup:exams]

+ 43 - 43
docs/reference/aggregations/misc.asciidoc

@@ -65,18 +65,18 @@ Then that piece of metadata will be returned in place for our `titles` terms agg
 [source,console-result]
 --------------------------------------------------
 {
-    "aggregations": {
-        "titles": {
-            "meta": {
-                "color" : "blue"
-            },
-            "doc_count_error_upper_bound" : 0,
-            "sum_other_doc_count" : 0,
-            "buckets": [
-            ]
-        }
-    },
-    ...
+  "aggregations": {
+    "titles": {
+      "meta": {
+        "color": "blue"
+      },
+      "doc_count_error_upper_bound": 0,
+      "sum_other_doc_count": 0,
+      "buckets": [
+      ]
+    }
+  },
+  ...
 }
 --------------------------------------------------
 // TESTRESPONSE[s/\.\.\./"took": "$body.took", "timed_out": false, "_shards": "$body._shards", "hits": "$body.hits"/]
@@ -121,40 +121,40 @@ In the response, the aggregations names will be changed to respectively `date_hi
 [source,console-result]
 --------------------------------------------------
 {
-    "aggregations": {
-        "date_histogram#tweets_over_time": { <1>
-            "buckets" : [
+  "aggregations": {
+    "date_histogram#tweets_over_time": {                    <1>
+      "buckets": [
+        {
+          "key_as_string": "2009-01-01T00:00:00.000Z",
+          "key": 1230768000000,
+          "doc_count": 5,
+          "top_hits#top_users": {                           <2>
+            "hits": {
+              "total": {
+                "value": 5,
+                "relation": "eq"
+            },
+              "max_score": 1.0,
+              "hits": [
                 {
-                    "key_as_string" : "2009-01-01T00:00:00.000Z",
-                    "key" : 1230768000000,
-                    "doc_count" : 5,
-                    "top_hits#top_users" : {  <2>
-                        "hits" : {
-                            "total" : {
-                                "value": 5,
-                                "relation": "eq"
-                            },
-                            "max_score" : 1.0,
-                            "hits" : [
-                                {
-                                  "_index": "twitter",
-                                  "_id": "0",
-                                  "_score": 1.0,
-                                  "_source": {
-                                    "date": "2009-11-15T14:12:12",
-                                    "message": "trying out Elasticsearch",
-                                    "user": "kimchy",
-                                    "likes": 0
-                                  }
-                                }
-                            ]
-                        }
-                    }
+                  "_index": "twitter",
+                  "_id": "0",
+                  "_score": 1.0,
+                  "_source": {
+                    "date": "2009-11-15T14:12:12",
+                    "message": "trying out Elasticsearch",
+                    "user": "kimchy",
+                    "likes": 0
+                  }
                 }
-            ]
+              ]
+            }
+          }
         }
-    },
-    ...
+      ]
+    }
+  },
+  ...
 }
 --------------------------------------------------
 // TESTRESPONSE[s/\.\.\./"took": "$body.took", "timed_out": false, "_shards": "$body._shards", "hits": "$body.hits"/]

+ 71 - 71
docs/reference/aggregations/pipeline.asciidoc

@@ -54,22 +54,22 @@ metric `"the_sum"`:
 --------------------------------------------------
 POST /_search
 {
-    "aggs": {
-        "my_date_histo":{
-            "date_histogram":{
-                "field":"timestamp",
-                "calendar_interval":"day"
-            },
-            "aggs":{
-                "the_sum":{
-                    "sum":{ "field": "lemmings" } <1>
-                },
-                "the_deriv":{
-                    "derivative":{ "buckets_path": "the_sum" } <2>
-                }
-            }
+  "aggs": {
+    "my_date_histo": {
+      "date_histogram": {
+        "field": "timestamp",
+        "calendar_interval": "day"
+      },
+      "aggs": {
+        "the_sum": {
+          "sum": { "field": "lemmings" }              <1>
+        },
+        "the_deriv": {
+          "derivative": { "buckets_path": "the_sum" } <2>
         }
+      }
     }
+  }
 }
 --------------------------------------------------
 
@@ -84,26 +84,26 @@ a metric embedded inside a sibling aggregation:
 --------------------------------------------------
 POST /_search
 {
-    "aggs" : {
-        "sales_per_month" : {
-            "date_histogram" : {
-                "field" : "date",
-                "calendar_interval" : "month"
-            },
-            "aggs": {
-                "sales": {
-                    "sum": {
-                        "field": "price"
-                    }
-                }
-            }
-        },
-        "max_monthly_sales": {
-            "max_bucket": {
-                "buckets_path": "sales_per_month>sales" <1>
-            }
+  "aggs": {
+    "sales_per_month": {
+      "date_histogram": {
+        "field": "date",
+        "calendar_interval": "month"
+      },
+      "aggs": {
+        "sales": {
+          "sum": {
+            "field": "price"
+          }
         }
+      }
+    },
+    "max_monthly_sales": {
+      "max_bucket": {
+        "buckets_path": "sales_per_month>sales" <1>
+      }
     }
+  }
 }
 --------------------------------------------------
 // TEST[setup:sales]
@@ -119,37 +119,37 @@ their bucket keys) to perform the calculation:
 --------------------------------------------------
 POST /_search
 {
-    "aggs" : {
-        "sales_per_month" : {
-            "date_histogram" : {
-                "field" : "date",
-                "calendar_interval" : "month"
-            },
-            "aggs": {
-                "sale_type": {
-                    "terms": {
-                        "field": "type"
-                    },
-                    "aggs": {
-                        "sales": {
-                            "sum": {
-                                "field": "price"
-                            }
-                        }
-                    }
-                },
-                "hat_vs_bag_ratio": {
-                    "bucket_script": {
-                        "buckets_path": {
-                            "hats": "sale_type['hat']>sales", <1>
-                            "bags": "sale_type['bag']>sales"  <1>
-                        },
-                        "script": "params.hats / params.bags"
-                    }
-                }
+  "aggs": {
+    "sales_per_month": {
+      "date_histogram": {
+        "field": "date",
+        "calendar_interval": "month"
+      },
+      "aggs": {
+        "sale_type": {
+          "terms": {
+            "field": "type"
+          },
+          "aggs": {
+            "sales": {
+              "sum": {
+                "field": "price"
+              }
             }
+          }
+        },
+        "hat_vs_bag_ratio": {
+          "bucket_script": {
+            "buckets_path": {
+              "hats": "sale_type['hat']>sales",   <1>
+              "bags": "sale_type['bag']>sales"    <1>
+            },
+            "script": "params.hats / params.bags"
+          }
         }
+      }
     }
+  }
 }
 --------------------------------------------------
 // TEST[setup:sales]
@@ -168,19 +168,19 @@ on the document count of each bucket, instead of a specific metric:
 --------------------------------------------------
 POST /_search
 {
-    "aggs": {
-        "my_date_histo": {
-            "date_histogram": {
-                "field":"timestamp",
-                "calendar_interval":"day"
-            },
-            "aggs": {
-                "the_deriv": {
-                    "derivative": { "buckets_path": "_count" } <1>
-                }
-            }
+  "aggs": {
+    "my_date_histo": {
+      "date_histogram": {
+        "field": "timestamp",
+        "calendar_interval": "day"
+      },
+      "aggs": {
+        "the_deriv": {
+          "derivative": { "buckets_path": "_count" } <1>
         }
+      }
     }
+  }
 }
 --------------------------------------------------
 

+ 3 - 3
docs/reference/aggregations/pipeline/avg-bucket-aggregation.asciidoc

@@ -12,9 +12,9 @@ An `avg_bucket` aggregation looks like this in isolation:
 [source,js]
 --------------------------------------------------
 {
-    "avg_bucket": {
-        "buckets_path": "the_sum"
-    }
+  "avg_bucket": {
+    "buckets_path": "the_sum"
+  }
 }
 --------------------------------------------------
 // NOTCONSOLE

+ 43 - 43
docs/reference/aggregations/pipeline/bucket-script-aggregation.asciidoc

@@ -12,13 +12,13 @@ A `bucket_script` aggregation looks like this in isolation:
 [source,js]
 --------------------------------------------------
 {
-    "bucket_script": {
-        "buckets_path": {
-            "my_var1": "the_sum", <1>
-            "my_var2": "the_value_count"
-        },
-        "script": "params.my_var1 / params.my_var2"
-    }
+  "bucket_script": {
+    "buckets_path": {
+      "my_var1": "the_sum",                     <1>
+      "my_var2": "the_value_count"
+    },
+    "script": "params.my_var1 / params.my_var2"
+  }
 }
 --------------------------------------------------
 // NOTCONSOLE
@@ -45,45 +45,45 @@ The following snippet calculates the ratio percentage of t-shirt sales compared
 --------------------------------------------------
 POST /sales/_search
 {
-    "size": 0,
-    "aggs" : {
-        "sales_per_month" : {
-            "date_histogram" : {
-                "field" : "date",
-                "calendar_interval" : "month"
-            },
-            "aggs": {
-                "total_sales": {
-                    "sum": {
-                        "field": "price"
-                    }
-                },
-                "t-shirts": {
-                  "filter": {
-                    "term": {
-                      "type": "t-shirt"
-                    }
-                  },
-                  "aggs": {
-                    "sales": {
-                      "sum": {
-                        "field": "price"
-                      }
-                    }
-                  }
-                },
-                "t-shirt-percentage": {
-                    "bucket_script": {
-                        "buckets_path": {
-                          "tShirtSales": "t-shirts>sales",
-                          "totalSales": "total_sales"
-                        },
-                        "script": "params.tShirtSales / params.totalSales * 100"
-                    }
-                }
+  "size": 0,
+  "aggs": {
+    "sales_per_month": {
+      "date_histogram": {
+        "field": "date",
+        "calendar_interval": "month"
+      },
+      "aggs": {
+        "total_sales": {
+          "sum": {
+            "field": "price"
+          }
+        },
+        "t-shirts": {
+          "filter": {
+            "term": {
+              "type": "t-shirt"
             }
+          },
+          "aggs": {
+            "sales": {
+              "sum": {
+                "field": "price"
+              }
+            }
+          }
+        },
+        "t-shirt-percentage": {
+          "bucket_script": {
+            "buckets_path": {
+              "tShirtSales": "t-shirts>sales",
+              "totalSales": "total_sales"
+            },
+            "script": "params.tShirtSales / params.totalSales * 100"
+          }
         }
+      }
     }
+  }
 }
 --------------------------------------------------
 // TEST[setup:sales]

+ 28 - 28
docs/reference/aggregations/pipeline/bucket-selector-aggregation.asciidoc

@@ -16,13 +16,13 @@ A `bucket_selector` aggregation looks like this in isolation:
 [source,js]
 --------------------------------------------------
 {
-    "bucket_selector": {
-        "buckets_path": {
-            "my_var1": "the_sum", <1>
-            "my_var2": "the_value_count"
-        },
-        "script": "params.my_var1 > params.my_var2"
-    }
+  "bucket_selector": {
+    "buckets_path": {
+      "my_var1": "the_sum",                     <1>
+      "my_var2": "the_value_count"
+    },
+    "script": "params.my_var1 > params.my_var2"
+  }
 }
 --------------------------------------------------
 // NOTCONSOLE
@@ -48,30 +48,30 @@ The following snippet only retains buckets where the total sales for the month i
 --------------------------------------------------
 POST /sales/_search
 {
-    "size": 0,
-    "aggs" : {
-        "sales_per_month" : {
-            "date_histogram" : {
-                "field" : "date",
-                "calendar_interval" : "month"
+  "size": 0,
+  "aggs": {
+    "sales_per_month": {
+      "date_histogram": {
+        "field": "date",
+        "calendar_interval": "month"
+      },
+      "aggs": {
+        "total_sales": {
+          "sum": {
+            "field": "price"
+          }
+        },
+        "sales_bucket_filter": {
+          "bucket_selector": {
+            "buckets_path": {
+              "totalSales": "total_sales"
             },
-            "aggs": {
-                "total_sales": {
-                    "sum": {
-                        "field": "price"
-                    }
-                },
-                "sales_bucket_filter": {
-                    "bucket_selector": {
-                        "buckets_path": {
-                          "totalSales": "total_sales"
-                        },
-                        "script": "params.totalSales > 200"
-                    }
-                }
-            }
+            "script": "params.totalSales > 200"
+          }
         }
+      }
     }
+  }
 }
 --------------------------------------------------
 // TEST[setup:sales]

+ 46 - 46
docs/reference/aggregations/pipeline/bucket-sort-aggregation.asciidoc

@@ -18,15 +18,15 @@ A `bucket_sort` aggregation looks like this in isolation:
 [source,js]
 --------------------------------------------------
 {
-    "bucket_sort": {
-        "sort": [
-            {"sort_field_1": {"order": "asc"}},<1>
-            {"sort_field_2": {"order": "desc"}},
-            "sort_field_3"
-        ],
-        "from": 1,
-        "size": 3
-    }
+  "bucket_sort": {
+    "sort": [
+      { "sort_field_1": { "order": "asc" } },   <1>
+      { "sort_field_2": { "order": "desc" } },
+      "sort_field_3"
+    ],
+    "from": 1,
+    "size": 3
+  }
 }
 --------------------------------------------------
 // NOTCONSOLE
@@ -51,30 +51,30 @@ The following snippet returns the buckets corresponding to the 3 months with the
 --------------------------------------------------
 POST /sales/_search
 {
-    "size": 0,
-    "aggs" : {
-        "sales_per_month" : {
-            "date_histogram" : {
-                "field" : "date",
-                "calendar_interval" : "month"
-            },
-            "aggs": {
-                "total_sales": {
-                    "sum": {
-                        "field": "price"
-                    }
-                },
-                "sales_bucket_sort": {
-                    "bucket_sort": {
-                        "sort": [
-                          {"total_sales": {"order": "desc"}}<1>
-                        ],
-                        "size": 3<2>
-                    }
-                }
-            }
+  "size": 0,
+  "aggs": {
+    "sales_per_month": {
+      "date_histogram": {
+        "field": "date",
+        "calendar_interval": "month"
+      },
+      "aggs": {
+        "total_sales": {
+          "sum": {
+            "field": "price"
+          }
+        },
+        "sales_bucket_sort": {
+          "bucket_sort": {
+            "sort": [
+              { "total_sales": { "order": "desc" } } <1>
+            ],
+            "size": 3                                <2>
+          }
         }
+      }
     }
+  }
 }
 --------------------------------------------------
 // TEST[setup:sales]
@@ -139,23 +139,23 @@ The following example simply truncates the result so that only the second bucket
 --------------------------------------------------
 POST /sales/_search
 {
-    "size": 0,
-    "aggs" : {
-        "sales_per_month" : {
-            "date_histogram" : {
-                "field" : "date",
-                "calendar_interval" : "month"
-            },
-            "aggs": {
-                "bucket_truncate": {
-                    "bucket_sort": {
-                        "from": 1,
-                        "size": 1
-                    }
-                }
-            }
+  "size": 0,
+  "aggs": {
+    "sales_per_month": {
+      "date_histogram": {
+        "field": "date",
+        "calendar_interval": "month"
+      },
+      "aggs": {
+        "bucket_truncate": {
+          "bucket_sort": {
+            "from": 1,
+            "size": 1
+          }
         }
+      }
     }
+  }
 }
 --------------------------------------------------
 // TEST[setup:sales]

+ 46 - 46
docs/reference/aggregations/pipeline/cumulative-cardinality-aggregation.asciidoc

@@ -19,9 +19,9 @@ A `cumulative_cardinality` aggregation looks like this in isolation:
 [source,js]
 --------------------------------------------------
 {
-    "cumulative_cardinality": {
-        "buckets_path": "my_cardinality_agg"
-    }
+  "cumulative_cardinality": {
+    "buckets_path": "my_cardinality_agg"
+  }
 }
 --------------------------------------------------
 // NOTCONSOLE
@@ -42,27 +42,27 @@ The following snippet calculates the cumulative cardinality of the total daily `
 --------------------------------------------------
 GET /user_hits/_search
 {
-    "size": 0,
-    "aggs" : {
-        "users_per_day" : {
-            "date_histogram" : {
-                "field" : "timestamp",
-                "calendar_interval" : "day"
-            },
-            "aggs": {
-                "distinct_users": {
-                    "cardinality": {
-                        "field": "user_id"
-                    }
-                },
-                "total_new_users": {
-                    "cumulative_cardinality": {
-                        "buckets_path": "distinct_users" <1>
-                    }
-                }
-            }
+  "size": 0,
+  "aggs": {
+    "users_per_day": {
+      "date_histogram": {
+        "field": "timestamp",
+        "calendar_interval": "day"
+      },
+      "aggs": {
+        "distinct_users": {
+          "cardinality": {
+            "field": "user_id"
+          }
+        },
+        "total_new_users": {
+          "cumulative_cardinality": {
+            "buckets_path": "distinct_users" <1>
+          }
         }
+      }
     }
+  }
 }
 --------------------------------------------------
 // TEST[setup:user_hits]
@@ -141,32 +141,32 @@ This can be accomplished by adding a `derivative` aggregation to our query:
 --------------------------------------------------
 GET /user_hits/_search
 {
-    "size": 0,
-    "aggs" : {
-        "users_per_day" : {
-            "date_histogram" : {
-                "field" : "timestamp",
-                "calendar_interval" : "day"
-            },
-            "aggs": {
-                "distinct_users": {
-                    "cardinality": {
-                        "field": "user_id"
-                    }
-                },
-                "total_new_users": {
-                    "cumulative_cardinality": {
-                        "buckets_path": "distinct_users"
-                    }
-                },
-                "incremental_new_users": {
-                    "derivative": {
-                        "buckets_path": "total_new_users"
-                    }
-                }
-            }
+  "size": 0,
+  "aggs": {
+    "users_per_day": {
+      "date_histogram": {
+        "field": "timestamp",
+        "calendar_interval": "day"
+      },
+      "aggs": {
+        "distinct_users": {
+          "cardinality": {
+            "field": "user_id"
+          }
+        },
+        "total_new_users": {
+          "cumulative_cardinality": {
+            "buckets_path": "distinct_users"
+          }
+        },
+        "incremental_new_users": {
+          "derivative": {
+            "buckets_path": "total_new_users"
+          }
         }
+      }
     }
+  }
 }
 --------------------------------------------------
 // TEST[setup:user_hits]

+ 22 - 22
docs/reference/aggregations/pipeline/cumulative-sum-aggregation.asciidoc

@@ -12,9 +12,9 @@ A `cumulative_sum` aggregation looks like this in isolation:
 [source,js]
 --------------------------------------------------
 {
-    "cumulative_sum": {
-        "buckets_path": "the_sum"
-    }
+  "cumulative_sum": {
+    "buckets_path": "the_sum"
+  }
 }
 --------------------------------------------------
 // NOTCONSOLE
@@ -35,27 +35,27 @@ The following snippet calculates the cumulative sum of the total monthly `sales`
 --------------------------------------------------
 POST /sales/_search
 {
-    "size": 0,
-    "aggs" : {
-        "sales_per_month" : {
-            "date_histogram" : {
-                "field" : "date",
-                "calendar_interval" : "month"
-            },
-            "aggs": {
-                "sales": {
-                    "sum": {
-                        "field": "price"
-                    }
-                },
-                "cumulative_sales": {
-                    "cumulative_sum": {
-                        "buckets_path": "sales" <1>
-                    }
-                }
-            }
+  "size": 0,
+  "aggs": {
+    "sales_per_month": {
+      "date_histogram": {
+        "field": "date",
+        "calendar_interval": "month"
+      },
+      "aggs": {
+        "sales": {
+          "sum": {
+            "field": "price"
+          }
+        },
+        "cumulative_sales": {
+          "cumulative_sum": {
+            "buckets_path": "sales" <1>
+          }
         }
+      }
     }
+  }
 }
 --------------------------------------------------
 // TEST[setup:sales]

+ 63 - 63
docs/reference/aggregations/pipeline/derivative-aggregation.asciidoc

@@ -38,27 +38,27 @@ The following snippet calculates the derivative of the total monthly `sales`:
 --------------------------------------------------
 POST /sales/_search
 {
-    "size": 0,
-    "aggs" : {
-        "sales_per_month" : {
-            "date_histogram" : {
-                "field" : "date",
-                "calendar_interval" : "month"
-            },
-            "aggs": {
-                "sales": {
-                    "sum": {
-                        "field": "price"
-                    }
-                },
-                "sales_deriv": {
-                    "derivative": {
-                        "buckets_path": "sales" <1>
-                    }
-                }
-            }
+  "size": 0,
+  "aggs": {
+    "sales_per_month": {
+      "date_histogram": {
+        "field": "date",
+        "calendar_interval": "month"
+      },
+      "aggs": {
+        "sales": {
+          "sum": {
+            "field": "price"
+          }
+        },
+        "sales_deriv": {
+          "derivative": {
+            "buckets_path": "sales" <1>
+          }
         }
+      }
     }
+  }
 }
 --------------------------------------------------
 // TEST[setup:sales]
@@ -131,32 +131,32 @@ monthly sales:
 --------------------------------------------------
 POST /sales/_search
 {
-    "size": 0,
-    "aggs" : {
-        "sales_per_month" : {
-            "date_histogram" : {
-                "field" : "date",
-                "calendar_interval" : "month"
-            },
-            "aggs": {
-                "sales": {
-                    "sum": {
-                        "field": "price"
-                    }
-                },
-                "sales_deriv": {
-                    "derivative": {
-                        "buckets_path": "sales"
-                    }
-                },
-                "sales_2nd_deriv": {
-                    "derivative": {
-                        "buckets_path": "sales_deriv" <1>
-                    }
-                }
-            }
+  "size": 0,
+  "aggs": {
+    "sales_per_month": {
+      "date_histogram": {
+        "field": "date",
+        "calendar_interval": "month"
+      },
+      "aggs": {
+        "sales": {
+          "sum": {
+            "field": "price"
+          }
+        },
+        "sales_deriv": {
+          "derivative": {
+            "buckets_path": "sales"
+          }
+        },
+        "sales_2nd_deriv": {
+          "derivative": {
+            "buckets_path": "sales_deriv" <1>
+          }
         }
+      }
     }
+  }
 }
 --------------------------------------------------
 // TEST[setup:sales]
@@ -230,28 +230,28 @@ of the total sales per month but ask for the derivative of the sales as in the u
 --------------------------------------------------
 POST /sales/_search
 {
-    "size": 0,
-    "aggs" : {
-        "sales_per_month" : {
-            "date_histogram" : {
-                "field" : "date",
-                "calendar_interval" : "month"
-            },
-            "aggs": {
-                "sales": {
-                    "sum": {
-                        "field": "price"
-                    }
-                },
-                "sales_deriv": {
-                    "derivative": {
-                        "buckets_path": "sales",
-                        "unit": "day" <1>
-                    }
-                }
-            }
+  "size": 0,
+  "aggs": {
+    "sales_per_month": {
+      "date_histogram": {
+        "field": "date",
+        "calendar_interval": "month"
+      },
+      "aggs": {
+        "sales": {
+          "sum": {
+            "field": "price"
+          }
+        },
+        "sales_deriv": {
+          "derivative": {
+            "buckets_path": "sales",
+            "unit": "day" <1>
+          }
         }
+      }
     }
+  }
 }
 --------------------------------------------------
 // TEST[setup:sales]

+ 22 - 22
docs/reference/aggregations/pipeline/extended-stats-bucket-aggregation.asciidoc

@@ -13,9 +13,9 @@ A `extended_stats_bucket` aggregation looks like this in isolation:
 [source,js]
 --------------------------------------------------
 {
-    "extended_stats_bucket": {
-        "buckets_path": "the_sum"
-    }
+  "extended_stats_bucket": {
+    "buckets_path": "the_sum"
+  }
 }
 --------------------------------------------------
 // NOTCONSOLE
@@ -39,27 +39,27 @@ The following snippet calculates the extended stats for monthly `sales` bucket:
 --------------------------------------------------
 POST /sales/_search
 {
-    "size": 0,
-    "aggs" : {
-        "sales_per_month" : {
-            "date_histogram" : {
-                "field" : "date",
-                "calendar_interval" : "month"
-            },
-            "aggs": {
-                "sales": {
-                    "sum": {
-                        "field": "price"
-                    }
-                }
-            }
-        },
-        "stats_monthly_sales": {
-            "extended_stats_bucket": {
-                "buckets_path": "sales_per_month>sales" <1>
-            }
+  "size": 0,
+  "aggs": {
+    "sales_per_month": {
+      "date_histogram": {
+        "field": "date",
+        "calendar_interval": "month"
+      },
+      "aggs": {
+        "sales": {
+          "sum": {
+            "field": "price"
+          }
         }
+      }
+    },
+    "stats_monthly_sales": {
+      "extended_stats_bucket": {
+        "buckets_path": "sales_per_month>sales" <1>
+      }
     }
+  }
 }
 --------------------------------------------------
 // TEST[setup:sales]

+ 11 - 11
docs/reference/aggregations/pipeline/inference-bucket-aggregation.asciidoc

@@ -17,18 +17,18 @@ A `inference` aggregation looks like this in isolation:
 [source,js]
 --------------------------------------------------
 {
-    "inference": {
-        "model_id": "a_model_for_inference", <1>
-        "inference_config": { <2>
-            "regression_config": {
-                "num_top_feature_importance_values": 2
-            }
-        },
-        "buckets_path": {
-            "avg_cost": "avg_agg", <3>
-            "max_cost": "max_agg"
-        }
+  "inference": {
+    "model_id": "a_model_for_inference", <1>
+    "inference_config": { <2>
+      "regression_config": {
+        "num_top_feature_importance_values": 2
+      }
+    },
+    "buckets_path": {
+      "avg_cost": "avg_agg", <3>
+          "max_cost": "max_agg"
     }
+  }
 }
 --------------------------------------------------
 // NOTCONSOLE

+ 22 - 22
docs/reference/aggregations/pipeline/max-bucket-aggregation.asciidoc

@@ -12,9 +12,9 @@ A `max_bucket` aggregation looks like this in isolation:
 [source,js]
 --------------------------------------------------
 {
-    "max_bucket": {
-        "buckets_path": "the_sum"
-    }
+  "max_bucket": {
+    "buckets_path": "the_sum"
+  }
 }
 --------------------------------------------------
 // NOTCONSOLE
@@ -37,27 +37,27 @@ The following snippet calculates the maximum of the total monthly `sales`:
 --------------------------------------------------
 POST /sales/_search
 {
-    "size": 0,
-    "aggs" : {
-        "sales_per_month" : {
-            "date_histogram" : {
-                "field" : "date",
-                "calendar_interval" : "month"
-            },
-            "aggs": {
-                "sales": {
-                    "sum": {
-                        "field": "price"
-                    }
-                }
-            }
-        },
-        "max_monthly_sales": {
-            "max_bucket": {
-                "buckets_path": "sales_per_month>sales" <1>
-            }
+  "size": 0,
+  "aggs": {
+    "sales_per_month": {
+      "date_histogram": {
+        "field": "date",
+        "calendar_interval": "month"
+      },
+      "aggs": {
+        "sales": {
+          "sum": {
+            "field": "price"
+          }
         }
+      }
+    },
+    "max_monthly_sales": {
+      "max_bucket": {
+        "buckets_path": "sales_per_month>sales" <1>
+      }
     }
+  }
 }
 --------------------------------------------------
 // TEST[setup:sales]

+ 22 - 22
docs/reference/aggregations/pipeline/min-bucket-aggregation.asciidoc

@@ -12,9 +12,9 @@ A `min_bucket` aggregation looks like this in isolation:
 [source,js]
 --------------------------------------------------
 {
-    "min_bucket": {
-        "buckets_path": "the_sum"
-    }
+  "min_bucket": {
+    "buckets_path": "the_sum"
+  }
 }
 --------------------------------------------------
 // NOTCONSOLE
@@ -37,27 +37,27 @@ The following snippet calculates the minimum of the total monthly `sales`:
 --------------------------------------------------
 POST /sales/_search
 {
-    "size": 0,
-    "aggs" : {
-        "sales_per_month" : {
-            "date_histogram" : {
-                "field" : "date",
-                "calendar_interval" : "month"
-            },
-            "aggs": {
-                "sales": {
-                    "sum": {
-                        "field": "price"
-                    }
-                }
-            }
-        },
-        "min_monthly_sales": {
-            "min_bucket": {
-                "buckets_path": "sales_per_month>sales" <1>
-            }
+  "size": 0,
+  "aggs": {
+    "sales_per_month": {
+      "date_histogram": {
+        "field": "date",
+        "calendar_interval": "month"
+      },
+      "aggs": {
+        "sales": {
+          "sum": {
+            "field": "price"
+          }
         }
+      }
+    },
+    "min_monthly_sales": {
+      "min_bucket": {
+        "buckets_path": "sales_per_month>sales" <1>
+      }
     }
+  }
 }
 --------------------------------------------------
 // TEST[setup:sales]

+ 214 - 214
docs/reference/aggregations/pipeline/movfn-aggregation.asciidoc

@@ -15,11 +15,11 @@ A `moving_fn` aggregation looks like this in isolation:
 [source,js]
 --------------------------------------------------
 {
-    "moving_fn": {
-        "buckets_path": "the_sum",
-        "window": 10,
-        "script": "MovingFunctions.min(values)"
-    }
+  "moving_fn": {
+    "buckets_path": "the_sum",
+    "window": 10,
+    "script": "MovingFunctions.min(values)"
+  }
 }
 --------------------------------------------------
 // NOTCONSOLE
@@ -42,27 +42,27 @@ embedded like any other metric aggregation:
 --------------------------------------------------
 POST /_search
 {
-    "size": 0,
-    "aggs": {
-        "my_date_histo":{                <1>
-            "date_histogram":{
-                "field":"date",
-                "calendar_interval":"1M"
-            },
-            "aggs":{
-                "the_sum":{
-                    "sum":{ "field": "price" } <2>
-                },
-                "the_movfn": {
-                    "moving_fn": {
-                        "buckets_path": "the_sum", <3>
-                        "window": 10,
-                        "script": "MovingFunctions.unweightedAvg(values)"
-                    }
-                }
-            }
+  "size": 0,
+  "aggs": {
+    "my_date_histo": {                  <1>
+      "date_histogram": {
+        "field": "date",
+        "calendar_interval": "1M"
+      },
+      "aggs": {
+        "the_sum": {
+          "sum": { "field": "price" }   <2>
+        },
+        "the_movfn": {
+          "moving_fn": {
+            "buckets_path": "the_sum",  <3>
+            "window": 10,
+            "script": "MovingFunctions.unweightedAvg(values)"
+          }
         }
+      }
     }
+  }
 }
 --------------------------------------------------
 // TEST[setup:sales]
@@ -143,27 +143,27 @@ For example, this script will simply return the first value from the window, or
 --------------------------------------------------
 POST /_search
 {
-    "size": 0,
-    "aggs": {
-        "my_date_histo":{
-            "date_histogram":{
-                "field":"date",
-                "calendar_interval":"1M"
-            },
-            "aggs":{
-                "the_sum":{
-                    "sum":{ "field": "price" }
-                },
-                "the_movavg": {
-                    "moving_fn": {
-                        "buckets_path": "the_sum",
-                        "window": 10,
-                        "script": "return values.length > 0 ? values[0] : Double.NaN"
-                    }
-                }
-            }
+  "size": 0,
+  "aggs": {
+    "my_date_histo": {
+      "date_histogram": {
+        "field": "date",
+        "calendar_interval": "1M"
+      },
+      "aggs": {
+        "the_sum": {
+          "sum": { "field": "price" }
+        },
+        "the_movavg": {
+          "moving_fn": {
+            "buckets_path": "the_sum",
+            "window": 10,
+            "script": "return values.length > 0 ? values[0] : Double.NaN"
+          }
         }
+      }
     }
+  }
 }
 --------------------------------------------------
 // TEST[setup:sales]
@@ -213,27 +213,27 @@ is only calculated over the real values. If the window is empty, or all values a
 --------------------------------------------------
 POST /_search
 {
-    "size": 0,
-    "aggs": {
-        "my_date_histo":{
-            "date_histogram":{
-                "field":"date",
-                "calendar_interval":"1M"
-            },
-            "aggs":{
-                "the_sum":{
-                    "sum":{ "field": "price" }
-                },
-                "the_moving_max": {
-                    "moving_fn": {
-                        "buckets_path": "the_sum",
-                        "window": 10,
-                        "script": "MovingFunctions.max(values)"
-                    }
-                }
-            }
+  "size": 0,
+  "aggs": {
+    "my_date_histo": {
+      "date_histogram": {
+        "field": "date",
+        "calendar_interval": "1M"
+      },
+      "aggs": {
+        "the_sum": {
+          "sum": { "field": "price" }
+        },
+        "the_moving_max": {
+          "moving_fn": {
+            "buckets_path": "the_sum",
+            "window": 10,
+            "script": "MovingFunctions.max(values)"
+          }
         }
+      }
     }
+  }
 }
 --------------------------------------------------
 // TEST[setup:sales]
@@ -255,27 +255,27 @@ is only calculated over the real values. If the window is empty, or all values a
 --------------------------------------------------
 POST /_search
 {
-    "size": 0,
-    "aggs": {
-        "my_date_histo":{
-            "date_histogram":{
-                "field":"date",
-                "calendar_interval":"1M"
-            },
-            "aggs":{
-                "the_sum":{
-                    "sum":{ "field": "price" }
-                },
-                "the_moving_min": {
-                    "moving_fn": {
-                        "buckets_path": "the_sum",
-                        "window": 10,
-                        "script": "MovingFunctions.min(values)"
-                    }
-                }
-            }
+  "size": 0,
+  "aggs": {
+    "my_date_histo": {
+      "date_histogram": {
+        "field": "date",
+        "calendar_interval": "1M"
+      },
+      "aggs": {
+        "the_sum": {
+          "sum": { "field": "price" }
+        },
+        "the_moving_min": {
+          "moving_fn": {
+            "buckets_path": "the_sum",
+            "window": 10,
+            "script": "MovingFunctions.min(values)"
+          }
         }
+      }
     }
+  }
 }
 --------------------------------------------------
 // TEST[setup:sales]
@@ -297,27 +297,27 @@ the sum is only calculated over the real values.  If the window is empty, or all
 --------------------------------------------------
 POST /_search
 {
-    "size": 0,
-    "aggs": {
-        "my_date_histo":{
-            "date_histogram":{
-                "field":"date",
-                "calendar_interval":"1M"
-            },
-            "aggs":{
-                "the_sum":{
-                    "sum":{ "field": "price" }
-                },
-                "the_moving_sum": {
-                    "moving_fn": {
-                        "buckets_path": "the_sum",
-                        "window": 10,
-                        "script": "MovingFunctions.sum(values)"
-                    }
-                }
-            }
+  "size": 0,
+  "aggs": {
+    "my_date_histo": {
+      "date_histogram": {
+        "field": "date",
+        "calendar_interval": "1M"
+      },
+      "aggs": {
+        "the_sum": {
+          "sum": { "field": "price" }
+        },
+        "the_moving_sum": {
+          "moving_fn": {
+            "buckets_path": "the_sum",
+            "window": 10,
+            "script": "MovingFunctions.sum(values)"
+          }
         }
+      }
     }
+  }
 }
 --------------------------------------------------
 // TEST[setup:sales]
@@ -341,27 +341,27 @@ This function accepts a collection of doubles and average, then returns the stan
 --------------------------------------------------
 POST /_search
 {
-    "size": 0,
-    "aggs": {
-        "my_date_histo":{
-            "date_histogram":{
-                "field":"date",
-                "calendar_interval":"1M"
-            },
-            "aggs":{
-                "the_sum":{
-                    "sum":{ "field": "price" }
-                },
-                "the_moving_sum": {
-                    "moving_fn": {
-                        "buckets_path": "the_sum",
-                        "window": 10,
-                        "script": "MovingFunctions.stdDev(values, MovingFunctions.unweightedAvg(values))"
-                    }
-                }
-            }
+  "size": 0,
+  "aggs": {
+    "my_date_histo": {
+      "date_histogram": {
+        "field": "date",
+        "calendar_interval": "1M"
+      },
+      "aggs": {
+        "the_sum": {
+          "sum": { "field": "price" }
+        },
+        "the_moving_sum": {
+          "moving_fn": {
+            "buckets_path": "the_sum",
+            "window": 10,
+            "script": "MovingFunctions.stdDev(values, MovingFunctions.unweightedAvg(values))"
+          }
         }
+      }
     }
+  }
 }
 --------------------------------------------------
 // TEST[setup:sales]
@@ -392,27 +392,27 @@ values.
 --------------------------------------------------
 POST /_search
 {
-    "size": 0,
-    "aggs": {
-        "my_date_histo":{
-            "date_histogram":{
-                "field":"date",
-                "calendar_interval":"1M"
-            },
-            "aggs":{
-                "the_sum":{
-                    "sum":{ "field": "price" }
-                },
-                "the_movavg": {
-                    "moving_fn": {
-                        "buckets_path": "the_sum",
-                        "window": 10,
-                        "script": "MovingFunctions.unweightedAvg(values)"
-                    }
-                }
-            }
+  "size": 0,
+  "aggs": {
+    "my_date_histo": {
+      "date_histogram": {
+        "field": "date",
+        "calendar_interval": "1M"
+      },
+      "aggs": {
+        "the_sum": {
+          "sum": { "field": "price" }
+        },
+        "the_movavg": {
+          "moving_fn": {
+            "buckets_path": "the_sum",
+            "window": 10,
+            "script": "MovingFunctions.unweightedAvg(values)"
+          }
         }
+      }
     }
+  }
 }
 --------------------------------------------------
 // TEST[setup:sales]
@@ -437,27 +437,27 @@ If the window is empty, or all values are `null`/`NaN`, `NaN` is returned as the
 --------------------------------------------------
 POST /_search
 {
-    "size": 0,
-    "aggs": {
-        "my_date_histo":{
-            "date_histogram":{
-                "field":"date",
-                "calendar_interval":"1M"
-            },
-            "aggs":{
-                "the_sum":{
-                    "sum":{ "field": "price" }
-                },
-                "the_movavg": {
-                    "moving_fn": {
-                        "buckets_path": "the_sum",
-                        "window": 10,
-                        "script": "MovingFunctions.linearWeightedAvg(values)"
-                    }
-                }
-            }
+  "size": 0,
+  "aggs": {
+    "my_date_histo": {
+      "date_histogram": {
+        "field": "date",
+        "calendar_interval": "1M"
+      },
+      "aggs": {
+        "the_sum": {
+          "sum": { "field": "price" }
+        },
+        "the_movavg": {
+          "moving_fn": {
+            "buckets_path": "the_sum",
+            "window": 10,
+            "script": "MovingFunctions.linearWeightedAvg(values)"
+          }
         }
+      }
     }
+  }
 }
 --------------------------------------------------
 // TEST[setup:sales]
@@ -488,27 +488,27 @@ values.
 --------------------------------------------------
 POST /_search
 {
-    "size": 0,
-    "aggs": {
-        "my_date_histo":{
-            "date_histogram":{
-                "field":"date",
-                "calendar_interval":"1M"
-            },
-            "aggs":{
-                "the_sum":{
-                    "sum":{ "field": "price" }
-                },
-                "the_movavg": {
-                    "moving_fn": {
-                        "buckets_path": "the_sum",
-                        "window": 10,
-                        "script": "MovingFunctions.ewma(values, 0.3)"
-                    }
-                }
-            }
+  "size": 0,
+  "aggs": {
+    "my_date_histo": {
+      "date_histogram": {
+        "field": "date",
+        "calendar_interval": "1M"
+      },
+      "aggs": {
+        "the_sum": {
+          "sum": { "field": "price" }
+        },
+        "the_movavg": {
+          "moving_fn": {
+            "buckets_path": "the_sum",
+            "window": 10,
+            "script": "MovingFunctions.ewma(values, 0.3)"
+          }
         }
+      }
     }
+  }
 }
 --------------------------------------------------
 // TEST[setup:sales]
@@ -545,27 +545,27 @@ values.
 --------------------------------------------------
 POST /_search
 {
-    "size": 0,
-    "aggs": {
-        "my_date_histo":{
-            "date_histogram":{
-                "field":"date",
-                "calendar_interval":"1M"
-            },
-            "aggs":{
-                "the_sum":{
-                    "sum":{ "field": "price" }
-                },
-                "the_movavg": {
-                    "moving_fn": {
-                        "buckets_path": "the_sum",
-                        "window": 10,
-                        "script": "MovingFunctions.holt(values, 0.3, 0.1)"
-                    }
-                }
-            }
+  "size": 0,
+  "aggs": {
+    "my_date_histo": {
+      "date_histogram": {
+        "field": "date",
+        "calendar_interval": "1M"
+      },
+      "aggs": {
+        "the_sum": {
+          "sum": { "field": "price" }
+        },
+        "the_movavg": {
+          "moving_fn": {
+            "buckets_path": "the_sum",
+            "window": 10,
+            "script": "MovingFunctions.holt(values, 0.3, 0.1)"
+          }
         }
+      }
     }
+  }
 }
 --------------------------------------------------
 // TEST[setup:sales]
@@ -610,27 +610,27 @@ values.
 --------------------------------------------------
 POST /_search
 {
-    "size": 0,
-    "aggs": {
-        "my_date_histo":{
-            "date_histogram":{
-                "field":"date",
-                "calendar_interval":"1M"
-            },
-            "aggs":{
-                "the_sum":{
-                    "sum":{ "field": "price" }
-                },
-                "the_movavg": {
-                    "moving_fn": {
-                        "buckets_path": "the_sum",
-                        "window": 10,
-                        "script": "if (values.length > 5*2) {MovingFunctions.holtWinters(values, 0.3, 0.1, 0.1, 5, false)}"
-                    }
-                }
-            }
+  "size": 0,
+  "aggs": {
+    "my_date_histo": {
+      "date_histogram": {
+        "field": "date",
+        "calendar_interval": "1M"
+      },
+      "aggs": {
+        "the_sum": {
+          "sum": { "field": "price" }
+        },
+        "the_movavg": {
+          "moving_fn": {
+            "buckets_path": "the_sum",
+            "window": 10,
+            "script": "if (values.length > 5*2) {MovingFunctions.holtWinters(values, 0.3, 0.1, 0.1, 5, false)}"
+          }
         }
+      }
     }
+  }
 }
 --------------------------------------------------
 // TEST[setup:sales]

+ 25 - 25
docs/reference/aggregations/pipeline/moving-percentiles-aggregation.asciidoc

@@ -16,10 +16,10 @@ A `moving_percentiles` aggregation looks like this in isolation:
 [source,js]
 --------------------------------------------------
 {
-    "moving_percentiles": {
-        "buckets_path": "the_percentile",
-        "window": 10
-    }
+  "moving_percentiles": {
+    "buckets_path": "the_percentile",
+    "window": 10
+  }
 }
 --------------------------------------------------
 // NOTCONSOLE
@@ -41,29 +41,29 @@ embedded like any other metric aggregation:
 --------------------------------------------------
 POST /_search
 {
-    "size": 0,
-    "aggs": {
-        "my_date_histo":{                <1>
-            "date_histogram":{
-                "field":"date",
-                "calendar_interval":"1M"
-            },
-            "aggs":{
-                "the_percentile":{        <2>
-                    "percentiles":{
-                      "field": "price",
-                      "percents": [ 1.0, 99.0 ]
-                     }
-                },
-                "the_movperc": {
-                    "moving_percentiles": {
-                        "buckets_path": "the_percentile", <3>
-                        "window": 10
-                    }
-                }
-            }
+  "size": 0,
+  "aggs": {
+    "my_date_histo": {                          <1>
+        "date_histogram": {
+        "field": "date",
+        "calendar_interval": "1M"
+      },
+      "aggs": {
+        "the_percentile": {                     <2>
+            "percentiles": {
+            "field": "price",
+            "percents": [ 1.0, 99.0 ]
+          }
+        },
+        "the_movperc": {
+          "moving_percentiles": {
+            "buckets_path": "the_percentile",   <3>
+            "window": 10
+          }
         }
+      }
     }
+  }
 }
 --------------------------------------------------
 // TEST[setup:sales]

+ 25 - 25
docs/reference/aggregations/pipeline/normalize-aggregation.asciidoc

@@ -13,10 +13,10 @@ A `normalize` aggregation looks like this in isolation:
 [source,js]
 --------------------------------------------------
 {
-    "normalize": {
-        "buckets_path": "normalized",
-        "method": "percent_of_sum"
-    }
+  "normalize": {
+    "buckets_path": "normalized",
+    "method": "percent_of_sum"
+  }
 }
 --------------------------------------------------
 // NOTCONSOLE
@@ -91,29 +91,29 @@ The following snippet calculates the percent of total sales for each month:
 --------------------------------------------------
 POST /sales/_search
 {
-    "size": 0,
-    "aggs" : {
-        "sales_per_month" : {
-            "date_histogram" : {
-                "field" : "date",
-                "calendar_interval" : "month"
-            },
-            "aggs": {
-                "sales": {
-                    "sum": {
-                        "field": "price"
-                    }
-                },
-                "percent_of_total_sales": {
-                    "normalize": {
-                        "buckets_path": "sales", <1>
-                        "method": "percent_of_sum",  <2>
-                        "format": "00.00%" <3>
-                    }
-                }
-            }
+  "size": 0,
+  "aggs": {
+    "sales_per_month": {
+      "date_histogram": {
+        "field": "date",
+        "calendar_interval": "month"
+      },
+      "aggs": {
+        "sales": {
+          "sum": {
+            "field": "price"
+          }
+        },
+        "percent_of_total_sales": {
+          "normalize": {
+            "buckets_path": "sales",          <1>
+            "method": "percent_of_sum",       <2>
+            "format": "00.00%"                <3>
+          }
         }
+      }
     }
+  }
 }
 --------------------------------------------------
 // TEST[setup:sales]

+ 23 - 23
docs/reference/aggregations/pipeline/percentiles-bucket-aggregation.asciidoc

@@ -11,9 +11,9 @@ A `percentiles_bucket` aggregation looks like this in isolation:
 [source,js]
 --------------------------------------------------
 {
-    "percentiles_bucket": {
-        "buckets_path": "the_sum"
-    }
+  "percentiles_bucket": {
+    "buckets_path": "the_sum"
+  }
 }
 --------------------------------------------------
 // NOTCONSOLE
@@ -38,28 +38,28 @@ The following snippet calculates the percentiles for the total monthly `sales` b
 --------------------------------------------------
 POST /sales/_search
 {
-    "size": 0,
-    "aggs" : {
-        "sales_per_month" : {
-            "date_histogram" : {
-                "field" : "date",
-                "calendar_interval" : "month"
-            },
-            "aggs": {
-                "sales": {
-                    "sum": {
-                        "field": "price"
-                    }
-                }
-            }
-        },
-        "percentiles_monthly_sales": {
-            "percentiles_bucket": {
-                "buckets_path": "sales_per_month>sales", <1>
-                "percents": [ 25.0, 50.0, 75.0 ] <2>
-            }
+  "size": 0,
+  "aggs": {
+    "sales_per_month": {
+      "date_histogram": {
+        "field": "date",
+        "calendar_interval": "month"
+      },
+      "aggs": {
+        "sales": {
+          "sum": {
+            "field": "price"
+          }
         }
+      }
+    },
+    "percentiles_monthly_sales": {
+      "percentiles_bucket": {
+        "buckets_path": "sales_per_month>sales", <1>
+        "percents": [ 25.0, 50.0, 75.0 ]         <2>
+      }
     }
+  }
 }
 --------------------------------------------------
 // TEST[setup:sales]

+ 4 - 4
docs/reference/aggregations/pipeline/serial-diff-aggregation.asciidoc

@@ -38,10 +38,10 @@ A `serial_diff` aggregation looks like this in isolation:
 [source,js]
 --------------------------------------------------
 {
-    "serial_diff": {
-        "buckets_path": "the_sum",
-        "lag": "7"
-    }
+  "serial_diff": {
+    "buckets_path": "the_sum",
+    "lag": "7"
+  }
 }
 --------------------------------------------------
 // NOTCONSOLE

+ 22 - 22
docs/reference/aggregations/pipeline/stats-bucket-aggregation.asciidoc

@@ -11,9 +11,9 @@ A `stats_bucket` aggregation looks like this in isolation:
 [source,js]
 --------------------------------------------------
 {
-    "stats_bucket": {
-        "buckets_path": "the_sum"
-    }
+  "stats_bucket": {
+    "buckets_path": "the_sum"
+  }
 }
 --------------------------------------------------
 // NOTCONSOLE
@@ -36,27 +36,27 @@ The following snippet calculates the stats for monthly `sales`:
 --------------------------------------------------
 POST /sales/_search
 {
-    "size": 0,
-    "aggs" : {
-        "sales_per_month" : {
-            "date_histogram" : {
-                "field" : "date",
-                "calendar_interval" : "month"
-            },
-            "aggs": {
-                "sales": {
-                    "sum": {
-                        "field": "price"
-                    }
-                }
-            }
-        },
-        "stats_monthly_sales": {
-            "stats_bucket": {
-                "buckets_path": "sales_per_month>sales" <1>
-            }
+  "size": 0,
+  "aggs": {
+    "sales_per_month": {
+      "date_histogram": {
+        "field": "date",
+        "calendar_interval": "month"
+      },
+      "aggs": {
+        "sales": {
+          "sum": {
+            "field": "price"
+          }
         }
+      }
+    },
+    "stats_monthly_sales": {
+      "stats_bucket": {
+        "buckets_path": "sales_per_month>sales" <1>
+      }
     }
+  }
 }
 --------------------------------------------------
 // TEST[setup:sales]

+ 22 - 22
docs/reference/aggregations/pipeline/sum-bucket-aggregation.asciidoc

@@ -11,9 +11,9 @@ A `sum_bucket` aggregation looks like this in isolation:
 [source,js]
 --------------------------------------------------
 {
-    "sum_bucket": {
-        "buckets_path": "the_sum"
-    }
+  "sum_bucket": {
+    "buckets_path": "the_sum"
+  }
 }
 --------------------------------------------------
 // NOTCONSOLE
@@ -36,27 +36,27 @@ The following snippet calculates the sum of all the total monthly `sales` bucket
 --------------------------------------------------
 POST /sales/_search
 {
-    "size": 0,
-    "aggs" : {
-        "sales_per_month" : {
-            "date_histogram" : {
-                "field" : "date",
-                "calendar_interval" : "month"
-            },
-            "aggs": {
-                "sales": {
-                    "sum": {
-                        "field": "price"
-                    }
-                }
-            }
-        },
-        "sum_monthly_sales": {
-            "sum_bucket": {
-                "buckets_path": "sales_per_month>sales" <1>
-            }
+  "size": 0,
+  "aggs": {
+    "sales_per_month": {
+      "date_histogram": {
+        "field": "date",
+        "calendar_interval": "month"
+      },
+      "aggs": {
+        "sales": {
+          "sum": {
+            "field": "price"
+          }
         }
+      }
+    },
+    "sum_monthly_sales": {
+      "sum_bucket": {
+        "buckets_path": "sales_per_month>sales" <1>
+      }
     }
+  }
 }
 --------------------------------------------------
 // TEST[setup:sales]