Limits and gotchas
Sizes
| What | Limit |
|---|---|
Document list: from + size | 10,000 |
terms buckets (options.size) | Elasticsearch default 10 if omitted. The app uses 3 by default and up to 10,000 |
Composite size | Default 10 if omitted, bounded by the cluster bucket limit (65,535) |
Documents per bucket (top_hits) | 1 to 100 |
cardinality | Exact up to about 40,000 distinct values, then approximate |
cardinality_precise | At most 500 buckets, aggregation mode, all groupings terms |
collect_terms | 100 values by default |
filteredDocCount | Capped at 10,000 (relation: 'gte') |
| Rows per aggregation | One response, no paging. Split by filter if you have more than you can handle |
Time zones
datetime-intervalbuckets anddatetime-componentvalues are computed in UTC. There is no time zone option. Convert in your code if you need local time.- Relative date filters using date math (
now-1M/M) are UTC. The Insights app computes them in the browser's zone and sends timestamps. - Timestamps as bucket keys are epoch milliseconds.
Empty and missing values
- Documents without a value in a grouped field are left out unless you use
includeMissing,missingAsFalseor amissingstage. includeMissingontermsadds a bucket with the keymissing(aggregation mode) ornull(composite mode). Use it on text fields. On numeric or date fields it can fail.booleanwithoutmissingAsFalsegives numeric keys0and1and a bucket with key0can be returned as an unnamed row. UsemissingAsFalse: true.sum/avgover an empty bucket return0or nothing depending on the type. Guard formulas.
Things that are silently ignored
- Filter items whose field is not in the source, or that have no value.
- Groupings and metrics whose
fieldis not in the source (the Insights app drops them, so a saved chart can show fewer series than configured). includeMissingIntervalsand interval bounds in composite mode.sizein aggregation mode (useoptions.sizeper grouping).
Choices you have to make yourself
- Top N by a metric: request all groups, sort and cut in code (see Sorting).
- OR and NOT filters: the app only does AND. Use
bool.shouldormust_notclauses yourself. - "Contains" for longer text: the n-gram index handles words up to 20 characters. Use
wildcardormatchfor more.
Errors
| Response | Cause |
|---|---|
400 { error: 'query/invalid', errors: [{ message }] } | Elasticsearch rejected the query: bad filter clause, a grouping type not allowed in composite mode, a window above 10,000, a text field without .keyword in a sort or terms |
500 internal-server-error | Missing aggMode with aggs, empty aggs in composite mode, no top_hits stage in composite mode, an unknown aggregation type, includeFieldTypes without fields, unknown region type |
404 source/not-found | Unknown source |
403 source/access-forbidden | Not allowed on this source |
sdk/aggregate-filter-must-be-array, sdk/aggregate-sort-must-be-array | SDK guards, filter/sort not arrays |
Empty rows although data exists | Composite mode: the last stage is not named docs. Filter matches nothing. Field name without .keyword |
A debugging checklist
- Send the request without
aggsfirst, to check that yourfilterreturns documents. - Check the field names against
Source(name).get()(fieldTypes). - For groups: check
keywordFieldnames (category.keyword), notcategory. - Add
aggMode. Always. - Log
result.filteredDocCountandresult.totalDocCountto see whether the filter matches. - Build the same query in the Insights app and compare.