这是我的ES有效载荷:
{
"filtered": {
"filter": {
"and": {
"filters": [
{
"status": [
"error",
"active",
"opt_out"
]
},
{
"group_ids": [
"UUIDs-go-here"
]
}
]
}
}
},
"aggs": {
"status_count": {
"terms": {
"field": "status"
}
}
}
}
我收到的错误是Parse Failure [No parser for element [filtered]]];
我遵循这个https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-and-filter.html来帮助建立我的过滤器,但显然我做错了
试试这个:
{
"query": {
"filtered": {
"filter": {
"and": {
"filters": [
{
"terms": {
"status": [
"error",
"active",
"opt_out"
]
}
},
{
"terms": {
"group_ids": [
"UUIDs-go-here"
]
}
}
]
}
}
}
},
"aggs": {
"status_count": {
"terms": {
"field": "status"
}
}
}
}
将整个filtered query
包装在查询语法中,因为filtered
是一种查询类型,而不是查询本身。然后,在and filters
中,还需要指定要运行的过滤器的类型和类型,因为status
不是一种过滤器。我在这里假设您正在寻找字段上的terms
过滤器。