esquery/aggs_filter_test.go

43 lines
872 B
Go
Raw Normal View History

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