esquery/aggs_filter_test.go
Caleb Champlin fc16427405
Features: Filter Aggregations, Nested Aggregations, Multi Match Queries, Highlights (#12)
* Add support for multi_match queries

* Add support for highlights

* Add support for nested aggregations and filtered aggregations

* Update README

* Fix formatting
2021-03-14 09:50:22 +02:00

43 lines
872 B
Go

package esquery
import "testing"
func TestFilterAggs(t *testing.T) {
runMapTests(t, []mapTest{
{
"filter agg: simple",
FilterAgg("filtered", Term("type", "t-shirt")),
map[string]interface{}{
"filter": map[string]interface{}{
"term": map[string]interface{}{
"type": map[string]interface{}{
"value": "t-shirt",
},
},
},
},
},
{
"filter agg: with aggs",
FilterAgg("filtered", Term("type", "t-shirt")).
Aggs(Avg("avg_price", "price")),
map[string]interface{}{
"filter": map[string]interface{}{
"term": map[string]interface{}{
"type": map[string]interface{}{
"value": "t-shirt",
},
},
},
"aggs": map[string]interface{}{
"avg_price": map[string]interface{}{
"avg": map[string]interface{}{
"field": "price",
},
},
},
},
},
})
}