Pārlūkot izejas kodu

Improve time-series error and documentation (#100018)

* Improve time-series error and documentation

* spotless fix

* Update docs/changelog/100018.yaml

* Fix changelist

* Change exception type
Kostas Krikellas 2 gadi atpakaļ
vecāks
revīzija
c7705aa32a

+ 5 - 0
docs/changelog/100018.yaml

@@ -0,0 +1,5 @@
+pr: 100018
+summary: Improve time-series error and documentation
+area: "TSDB"
+type: enhancement
+issues: []

+ 0 - 4
docs/reference/aggregations/bucket/time-series-aggregation.asciidoc

@@ -67,8 +67,6 @@ PUT /my-time-series-index-0/_bulk
 --------------------------------------------------
 // NOTCONSOLE
 
-//////////////////////////
-
 To perform a time series aggregation, specify "time_series" as the aggregation type. When the boolean "keyed"
 is true, each bucket is given a unique key.
 
@@ -85,8 +83,6 @@ GET /_search
 --------------------------------------------------
 // NOTCONSOLE
 
-//////////////////////////
-
 This will return all results in the time series, however a more typical query will use sub aggregations to reduce the
 date returned to something more relevant.
 

+ 6 - 0
server/src/main/java/org/elasticsearch/search/aggregations/AggregationExecutionContext.java

@@ -53,6 +53,12 @@ public class AggregationExecutionContext {
     }
 
     public int getTsidOrd() {
+        if (tsidOrdProvider == null) {
+            throw new IllegalArgumentException(
+                "Aggregation on a time-series field is misconfigured, likely due to lack of wrapping "
+                    + "a metric aggregation within a `time-series` aggregation"
+            );
+        }
         return tsidOrdProvider.getAsInt();
     }
 }