Browse Source

Document that pipeline aggs cannot be used for sorting

Closes #20037
Clinton Gormley 9 years ago
parent
commit
31e5e0b17f
1 changed files with 20 additions and 10 deletions
  1. 20 10
      docs/reference/aggregations/bucket/terms-aggregation.asciidoc

+ 20 - 10
docs/reference/aggregations/bucket/terms-aggregation.asciidoc

@@ -244,9 +244,18 @@ determined and is given a value of -1 to indicate this.
 ==== Order
 
 The order of the buckets can be customized by setting the `order` parameter. By default, the buckets are ordered by
-their `doc_count` descending. It is also possible to change this behaviour as follows:
+their `doc_count` descending.  It is possible to change this behaviour as documented below:
 
-Ordering the buckets by their `doc_count` in an ascending manner:
+WARNING: Sorting by ascending `_count` or by sub aggregation is discouraged as it increases the
+<<search-aggregations-bucket-terms-aggregation-approximate-counts,error>> on document counts.
+It is fine when a single shard is queried, or when the field that is being aggregated was used
+as a routing key at index time: in these cases results will be accurate since shards have disjoint
+values. However otherwise, errors are unbounded. One particular case that could still be useful
+is sorting by <<search-aggregations-metrics-min-aggregation,`min`>> or
+<<search-aggregations-metrics-max-aggregation,`max`>> aggregation: counts will not be accurate
+but at least the top buckets will be correctly picked.
+
+Ordering the buckets by their doc `_count` in an ascending manner:
 
 [source,js]
 --------------------------------------------------
@@ -317,14 +326,15 @@ Ordering the buckets by multi value metrics sub-aggregation (identified by the a
 }
 --------------------------------------------------
 
-WARNING: Sorting by ascending `_count` or by sub aggregation is discouraged as it increases the
-<<search-aggregations-bucket-terms-aggregation-approximate-counts,error>> on document counts.
-It is fine when a single shard is queried, or when the field that is being aggregated was used
-as a routing key at index time: in these cases results will be accurate since shards have disjoint
-values. However otherwise, errors are unbounded. One particular case that could still be useful
-is sorting by <<search-aggregations-metrics-min-aggregation,`min`>> or
-<<search-aggregations-metrics-max-aggregation,`max`>> aggregation: counts will not be accurate
-but at least the top buckets will be correctly picked.
+.Pipeline aggs cannot be used for sorting
+[INFO]
+=======================================
+
+<<search-aggregations-pipeline,Pipeline aggregations>> are run during the
+reduce phase after all other aggregations have already completed.  For this
+reason, they cannot be used for ordering.
+
+=======================================
 
 It is also possible to order the buckets based on a "deeper" aggregation in the hierarchy. This is supported as long
 as the aggregations path are of a single-bucket type, where the last aggregation in the path may either be a single-bucket