* Add analyzer documentation Signed-off-by: Fanit Kolchina <kolchfa@amazon.com> * Add index and search analyzer pages Signed-off-by: Fanit Kolchina <kolchfa@amazon.com> * Doc review comments Signed-off-by: Fanit Kolchina <kolchfa@amazon.com> * Apply suggestions from code review Co-authored-by: Melissa Vagi <vagimeli@amazon.com> Signed-off-by: kolchfa-aws <105444904+kolchfa-aws@users.noreply.github.com> * More doc review comments Signed-off-by: Fanit Kolchina <kolchfa@amazon.com> * Apply suggestions from code review Co-authored-by: Nathan Bower <nbower@amazon.com> Signed-off-by: kolchfa-aws <105444904+kolchfa-aws@users.noreply.github.com> * Implemented editorial comments Signed-off-by: Fanit Kolchina <kolchfa@amazon.com> * Update index-analyzers.md Signed-off-by: kolchfa-aws <105444904+kolchfa-aws@users.noreply.github.com> --------- Signed-off-by: Fanit Kolchina <kolchfa@amazon.com> Signed-off-by: kolchfa-aws <105444904+kolchfa-aws@users.noreply.github.com> Co-authored-by: Melissa Vagi <vagimeli@amazon.com> Co-authored-by: Nathan Bower <nbower@amazon.com>
56 lines
1.1 KiB
Markdown
56 lines
1.1 KiB
Markdown
---
|
|
layout: default
|
|
title: Filter
|
|
parent: Bucket aggregations
|
|
grand_parent: Aggregations
|
|
nav_order: 50
|
|
redirect_from:
|
|
- /query-dsl/aggregations/bucket/filter/
|
|
---
|
|
|
|
# Filter aggregations
|
|
|
|
A `filter` aggregation is a query clause, exactly like a search query — `match` or `term` or `range`. You can use the `filter` aggregation to narrow down the entire set of documents to a specific set before creating buckets.
|
|
|
|
The following example shows the `avg` aggregation running within the context of a filter. The `avg` aggregation only aggregates the documents that match the `range` query:
|
|
|
|
```json
|
|
GET opensearch_dashboards_sample_data_ecommerce/_search
|
|
{
|
|
"size": 0,
|
|
"aggs": {
|
|
"low_value": {
|
|
"filter": {
|
|
"range": {
|
|
"taxful_total_price": {
|
|
"lte": 50
|
|
}
|
|
}
|
|
},
|
|
"aggs": {
|
|
"avg_amount": {
|
|
"avg": {
|
|
"field": "taxful_total_price"
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
```
|
|
{% include copy-curl.html %}
|
|
|
|
#### Example response
|
|
|
|
```json
|
|
...
|
|
"aggregations" : {
|
|
"low_value" : {
|
|
"doc_count" : 1633,
|
|
"avg_amount" : {
|
|
"value" : 38.363175998928355
|
|
}
|
|
}
|
|
}
|
|
}
|
|
``` |