我的索引映射如下所示:
curl -X PUT localhost:9200/testing/listings/_mapping -d '{
"listings" : {
"properties" : {
"address" : {
"properties": {
"location": { "type" : "string",
"index" : "not_analyzed"
}
}
},
"suggest" : {
"type" : "completion",
"index_analyzer" : "simple",
"search_analyzer" : "simple",
"payloads" : true
}
}
}
}'
我需要在 elasticsearch 中执行以下查询的操作
SELECT * FROM LISTINGS WHERE (published = true AND inActive = false) AND (residentialKind = "Villa" OR residentialKind = "Apartment");
为了执行上述查询操作,我在 elasticsearch 中使用了以下嵌套 bool 查询。
{"query":{
"filtered": {
"filter": {
"bool":{
"must":[
{"match":{"published":true}},
{"match":{"inActive":false}},
{"bool":
{"should": [
{"term":{"residentialKind":"Villa"}},
{"term":{"residentialKind":"Apartment"}}
]
}
}
]
}
}
}
}
}
它给出以下错误
{
"error": "SearchPhaseExecutionException[Failed to execute phase [query], all shards failed; shardFailures {[B5SbtdlkQTGL0WU-dvg2yg][propgod][0]: SearchParseException[[propgod][0]: from[-1],size[-1]: Parse Failure [Failed to parse source [{\"query\":{\n\t\"filtered\": {\n \t\"filter\": {\n \t\t\"bool\":{\n \t\t\t\"must\":[\n {\"match\":{\"published\":true}},\n {\"match\":{\"inActive\":false}},\n {\"bool\":\n \t\t{\"should\": [\n \t\t{\"term\":{\"residentialKind\":\"Villa\"}},\n {\"term\":{\"residentialKind\":\"Apartment\"}} \n \t]\n }\n }\n \t\t\t]\n \t\t\t}\n \t}\n }\n }\n}]]]; nested: QueryParsingException[[propgod] No filter registered for [match]]; }{[B5SbtdlkQTGL0WU-dvg2yg][propgod][1]: SearchParseException[[propgod][1]: from[-1],size[-1]: Parse Failure [Failed to parse source [{\"query\":{\n\t\"filtered\": {\n \t\"filter\": {\n \t\t\"bool\":{\n \t\t\t\"must\":[\n {\"match\":{\"published\":true}},\n {\"match\":{\"inActive\":false}},\n {\"bool\":\n \t\t{\"should\": [\n \t\t{\"term\":{\"residentialKind\":\"Villa\"}},\n {\"term\":{\"residentialKind\":\"Apartment\"}} \n \t]\n }\n }\n \t\t\t]\n \t\t\t}\n \t}\n }\n }\n}]]]; nested: QueryParsingException[[propgod] No filter registered for [match]]; }{[B5SbtdlkQTGL0WU-dvg2yg][propgod][2]: SearchParseException[[propgod][2]: from[-1],size[-1]: Parse Failure [Failed to parse source [{\"query\":{\n\t\"filtered\": {\n \t\"filter\": {\n \t\t\"bool\":{\n \t\t\t\"must\":[\n {\"match\":{\"published\":true}},\n {\"match\":{\"inActive\":false}},\n {\"bool\":\n \t\t{\"should\": [\n \t\t{\"term\":{\"residentialKind\":\"Villa\"}},\n {\"term\":{\"residentialKind\":\"Apartment\"}} \n \t]\n }\n }\n \t\t\t]\n \t\t\t}\n \t}\n }\n }\n}]]]; nested: QueryParsingException[[propgod] No filter registered for [match]]; }{[B5SbtdlkQTGL0WU-dvg2yg][propgod][3]: SearchParseException[[propgod][3]: from[-1],size[-1]: Parse Failure [Failed to parse source [{\"query\":{\n\t\"filtered\": {\n \t\"filter\": {\n \t\t\"bool\":{\n \t\t\t\"must\":[\n {\"match\":{\"published\":true}},\n {\"match\":{\"inActive\":false}},\n {\"bool\":\n \t\t{\"should\": [\n \t\t{\"term\":{\"residentialKind\":\"Villa\"}},\n {\"term\":{\"residentialKind\":\"Apartment\"}} \n \t]\n }\n }\n \t\t\t]\n \t\t\t}\n \t}\n }\n }\n}]]]; nested: QueryParsingException[[propgod] No filter registered for [match]]; }{[B5SbtdlkQTGL0WU-dvg2yg][propgod][4]: SearchParseException[[propgod][4]: from[-1],size[-1]: Parse Failure [Failed to parse source [{\"query\":{\n\t\"filtered\": {\n \t\"filter\": {\n \t\t\"bool\":{\n \t\t\t\"must\":[\n {\"match\":{\"published\":true}},\n {\"match\":{\"inActive\":false}},\n {\"bool\":\n \t\t{\"should\": [\n \t\t{\"term\":{\"residentialKind\":\"Villa\"}},\n {\"term\":{\"residentialKind\":\"Apartment\"}} \n \t]\n }\n }\n \t\t\t]\n \t\t\t}\n \t}\n }\n }\n}]]]; nested: QueryParsingException[[propgod] No filter registered for [match]]; }]",
"status": 400
}
因此,如果我的查询有误,请帮助我修复此查询。提前致谢。