-
Notifications
You must be signed in to change notification settings - Fork 25.8k
T digest field type docs #140478
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
not-napoleon
merged 22 commits into
elastic:main
from
not-napoleon:t-digest-field-type-docs
Jan 27, 2026
+145
−11
Merged
T digest field type docs #140478
Changes from all commits
Commits
Show all changes
22 commits
Select commit
Hold shift + click to select a range
c6a1c39
main field type doc
not-napoleon 5fd58cd
references
not-napoleon 3e9b64f
Merge branch 'main' into t-digest-field-type-docs
not-napoleon 0657deb
Merge branch 'main' into t-digest-field-type-docs
not-napoleon ae59b37
Apply suggestions from code review
not-napoleon 3bc161b
Merge remote-tracking branch 'refs/remotes/not-napoleon/t-digest-fiel…
not-napoleon f590230
Update docs/reference/elasticsearch/mapping-reference/field-data-type…
not-napoleon edea0bd
Merge remote-tracking branch 'refs/remotes/not-napoleon/t-digest-fiel…
not-napoleon 612c151
Update docs/changelog/140478.yaml
not-napoleon d920edb
requeted changes
not-napoleon 111a92b
Merge remote-tracking branch 'refs/remotes/not-napoleon/t-digest-fiel…
not-napoleon 0692e14
Merge branch 'main' into t-digest-field-type-docs
not-napoleon a5de408
[CI] Auto commit changes from spotless
2bf78a7
spotless apply
not-napoleon 6d239a1
Merge remote-tracking branch 'refs/remotes/not-napoleon/t-digest-fiel…
not-napoleon 2e7423a
requeted changes
not-napoleon 826bad6
Merge branch 'main' into t-digest-field-type-docs
not-napoleon c5b6014
fix internal links
not-napoleon c9a4f0c
Merge remote-tracking branch 'refs/remotes/not-napoleon/t-digest-fiel…
not-napoleon 80cb581
requeted changes
not-napoleon 1fbe1b0
Merge branch 'main' into t-digest-field-type-docs
not-napoleon 4aa5c1d
Merge branch 'main' into t-digest-field-type-docs
not-napoleon File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| pr: 140478 | ||
| summary: T digest field type docs | ||
| area: Mapping | ||
| type: enhancement | ||
| issues: [] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
123 changes: 123 additions & 0 deletions
123
docs/reference/elasticsearch/mapping-reference/t-digest.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,123 @@ | ||
| --- | ||
| applies_to: | ||
| stack: preview 9.3 | ||
| serverless: preview | ||
| navigation_title: "T-digest" | ||
| --- | ||
|
|
||
| # T-digest field type [tdigest] | ||
|
|
||
| A field to store pre-aggregated numerical data constructed using the [T-Digest](/reference/aggregations/search-aggregations-metrics-percentile-aggregation.md) algorithm. | ||
|
|
||
| ## Structure of a `tdigest` field | ||
|
|
||
| A `tdigest` field requires two arrays: | ||
|
|
||
| * A `centroids` array of | ||
| [`double`](/reference/elasticsearch/mapping-reference/number.md), containing | ||
| the computed centroids. These must be provided in ascending order. | ||
| * A `counts` array of | ||
| [`long`](/reference/elasticsearch/mapping-reference/number.md), containing the | ||
| computed counts for each of the centroids. This must be the same length as | ||
| the `centroids` array | ||
|
|
||
| The field also accepts three optional summary fields: | ||
|
|
||
| * `sum`, a [`double`](/reference/elasticsearch/mapping-reference/number.md), | ||
| representing the sum of the values being summarized by the t-digest | ||
| * `min`, a [`double`](/reference/elasticsearch/mapping-reference/number.md), | ||
| representing the minimum of the values being summarized by the t-digest | ||
| * `max`, a [`double`](/reference/elasticsearch/mapping-reference/number.md), | ||
| representing the maximum of the values being summarized by the t-digest | ||
|
|
||
| Specifying the summary values enables them to be calculated with | ||
| higher accuracy from the raw data. If not specified, Elasticsearch | ||
| computes them based on the given `centroids` and `counts`, with some loss of | ||
| accuracy. | ||
|
|
||
| ## Limitations | ||
|
|
||
| * A `tdigest` field can only store a single sketch per document. Multi-values or nested arrays are not supported. | ||
| * `tdigest` fields do not support sorting and are not searchable. | ||
|
|
||
|
|
||
| ## Configuring T-Digest Fields | ||
|
|
||
| T-Digest fields accept two field-specific configuration parameters: | ||
|
|
||
| * `compression`, a | ||
| [`double`](/reference/elasticsearch/mapping-reference/number.md) between `0` and | ||
| `10000` (excluding `0`), which corresponds to the parameter of the same name in | ||
| the [T-Digest](/reference/aggregations/search-aggregations-metrics-percentile-aggregation.md) algorithm. | ||
| In general, the higher this number, the more space on disk the field will use | ||
| but the more accurate the sketch approximations will be. Default is `100` | ||
| * `digest_type`, which selects the merge strategy to use with the sketch. Valid | ||
| values are `default` and `high_accuracy`. The default is `default`. The | ||
| `default` is optimized for storage and performance, while still producing a | ||
| good approximation. The `high_accuracy` variant uses more memory, disk, and | ||
| CPU for a better approximation. | ||
|
|
||
| ## Use cases [tdigest-use-cases] | ||
|
|
||
| `tdigest` fields are primarily intended for use with aggregations. To make them | ||
| efficient for aggregations, the data are stored as compact [doc | ||
| values](/reference/elasticsearch/mapping-reference/doc-values.md) and not | ||
| indexed. | ||
|
|
||
| `tdigest` fields are supported in the following [ES|QL](/reference/query-languages/esql.md) aggregation functions: | ||
|
|
||
| * [Avg](/reference/query-languages/esql/functions-operators/aggregation-functions.md#esql-avg) | ||
| * [Max](/reference/query-languages/esql/functions-operators/aggregation-functions.md#esql-max) | ||
| and | ||
| [Min](/reference/query-languages/esql/functions-operators/aggregation-functions.md#esql-min) | ||
| * [Percentile](/reference/query-languages/esql/functions-operators/aggregation-functions.md#esql-percentile) | ||
| * [Present](/reference/query-languages/esql/functions-operators/aggregation-functions.md#esql-present) and | ||
| [Absent](/reference/query-languages/esql/functions-operators/aggregation-functions.md#esql-absent) | ||
|
|
||
|
|
||
| ## Synthetic `_source` [tdigest-synthetic-source] | ||
|
|
||
| `tdigest` fields support [synthetic `_source`](/reference/elasticsearch/mapping-reference/mapping-source-field.md#synthetic-source) in their default configuration. | ||
|
|
||
| ::::{note} | ||
| To save space, zero-count buckets are not stored in `tdigest` doc values. If you index a `tdigest` field with zero-count buckets and synthetic `_source` is enabled, those buckets won't appear when you retrieve the field. | ||
| :::: | ||
|
|
||
| ## Examples | ||
|
|
||
| ### Create an index with a `tdigest` field | ||
|
|
||
| ```console | ||
| PUT my-index-000001 | ||
| { | ||
| "mappings": { | ||
| "properties": { | ||
| "latency": { | ||
| "type": "tdigest" | ||
| } | ||
| } | ||
| } | ||
| } | ||
| ``` | ||
|
|
||
| ### Index a simple document | ||
|
|
||
| ```console | ||
| PUT my-index-000001/_doc/1 | ||
| { | ||
| "latency": { | ||
| "centroids": [0.1, 0.2, 0.3, 0.4, 0.5], | ||
| "counts": [3, 7, 23, 12, 6] | ||
| } | ||
| } | ||
| ``` | ||
|
|
||
kkrik-es marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| ### Query via ES|QL | ||
|
|
||
| ```console | ||
| POST /_query?format=txt | ||
| { | ||
| "query": "FROM test | STATS Percentile(99, latency)" | ||
| } | ||
|
|
||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.