我无法使用过滤器或查询使用运算符“AND”执行查询。
我读了:
- http://www.elasticsearch.org/guide/reference/query-dsl/bool-query/
- http://www.elasticsearch.org/guide/reference/query-dsl/and-filter/
我努力了:
'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"}}
]
}
}
} '
此查询不会返回错误消息,但会返回我的集合的所有记录。