与this帖子一样,我无法使用过滤器工作:
GET files/_search
{
"query": {
"match": {
"words": "sugar"
}
},
"aggs": {
"xxx": {
"filters": {
"filter_list": {
"errors": {
"term": {
"abstract": "error"
}
},
"warnings": {
"term": {
"abstract": "warning"
}
}
}
},
"aggs": {
"st": {
"significant_terms": {
"field": "abstract"
}
}
}
}
}
}
SearchParseException [[files] [3]:query [words:sugar],from [-1],size [-1]: 解析失败[[xxx]中START_OBJECT的未知密钥: [filter_list]]]。 } {[tIS8uY8nTDil6kWtgsbkQg] [文件] [4]: SearchParseException [[files] [4]:查询[words:sugar],从[-1],size [-1]: 解析失败[无法解析源[{\ n \"查询\":{\ n
\"匹配\":{\ n \"字数":\"糖\" \ n} \ n},\ n \&# 34; aggs \":{\ n \" xxx \":{\ n \"过滤器\":{\ n \" filter_list \":{\ n
\"错误\":{\ n \" term \":{\ n \" abstract \": \"错误\" \ n} \ n},\ n \"警告\":{\ n
\" term \":{\ n \" abstract \":\" warning \" \ n} \ n } \ n} \ n},\ n \" aggs \":{\ n \" st \":{\ n
\" significant_terms \":{\ n \"字段\":\" abstract \" \ n
} \ n} \ n} \ n} \ n} \ n} \ n]]];嵌套: SearchParseException [[epars] [4]:查询[words:sugar],从[-1],size [-1]: 解析失败[[xxx]中START_OBJECT的未知密钥: [filter_list]]]。 }]"," status":400}
答案 0 :(得分:1)
您只有一件事是错误的,即filter_list
应该阅读filters
,因为它是filters
aggregation的必填元素。
GET files/_search
{
"query": {
"match": {
"words": "sugar"
}
},
"aggs": {
"xxx": {
"filters": {
"filters": { <---- change this
"errors": {
"term": {
"abstract": "error"
}
},
"warnings": {
"term": {
"abstract": "warning"
}
}
}
},
"aggs": {
"st": {
"significant_terms": {
"field": "abstract"
}
}
}
}
}
}