我无法使用过滤器或查询对运算符“AND”执行查询。
我读过:
我试过了:
'curl -XGET url_local:9200/chasseur_de_tete/cv/_search -d ' {
"filtered" : {
"query" : {
"match_all" : {} },
"filter" : {
"and" : {
"filters" : [
{"term" : {"active" : true }},
{ "term" : { "deleted" : false }}
]
}
}
}
} '
这会产生以下错误:
{
"error": "SearchPhaseExecutionException[Failed to execute phase [query], total failure; shardFailures {[9Fx2f7-MSNyYATEMPgemLw][chasseur_de_tete][4]: SearchParseException[[chasseur_de_tete][4]: from[-1],size[-1]: Parse Failure [Failed to parse source [ { \"filtered\" : { \"query\" : { \"match_all\" : {} }, \"filter\" : { \"and\" : { \"filters\" : [{ \"term\" : { \"active\" : \"true\" }},{ \"term\" : { \"deleted\" : \"false\" }}] } }}} ]]]; nested: SearchParseException[[chasseur_de_tete][4]: from[-1],size[-1]: Parse Failure [No parser for element [filtered]]]; }{[9Fx2f7-MSNyYATEMPgemLw][chasseur_de_tete][3]: SearchParseException[[chasseur_de_tete][3]: from[-1],size[-1]: Parse Failure [Failed to parse source [ { \"filtered\" : { \"query\" : { \"match_all\" : {} }, \"filter\" : { \"and\" : { \"filters\" : [{ \"term\" : { \"active\" : \"true\" }},{ \"term\" : { \"deleted\" : \"false\" }}] } }}} ]]]; nested: SearchParseException[[chasseur_de_tete][3]: from[-1],size[-1]: Parse Failure [No parser for element [filtered]]]; }]",
"status": 500
}
我也尝试过:
`curl url_local:9200/chasseur_de_tete/joboffer/_search -d '{
"query" : {
"bool" : {
"must" : [
{"term":{"active":"false"}},
{"term":{"deleted":"true"}}
]
}
}
} '
此查询不会返回错误消息,但会返回我的集合的所有记录。
答案 0 :(得分:5)
尝试:
{
"query": {
"constant_score": {
"filter": {
"bool": {
"must": [
{
"term": {
"active": false
}
},
{
"term": {
"deleted": true
}
}
]
}
}
}
}
}
您需要在请求正文中发布它。