当我尝试创建像
这样的查询时var my_query = new Object("[{ \"match\": { \"techskills.programming\":"+ programming+" } }]");
var deferred = Q.defer();
client.search({
"index": _index,
"type": _type,
"body": {
"query": {
"bool": {
"must": my_query
}
}
}
},function (error,resp) {
console.log("Found error is ::::: "+error + " resp::: "+JSON.stringify(resp));
if(error) deferred.reject(error);
deferred.resolve(resp);
});
return deferred.promise;
我收到以下错误:
[query_parsing_exception] [bool]查询不支持[必须]
答案 0 :(得分:0)
我通过将完整的body标记创建为动态查询字符串并将此变量传递给elasticsearch查询来解决此问题。 例如: var my_query =“{\”query \“:{\”bool \“:{\”must \“:[{\”match \“:{\”techskills.programming \“:\”“+ programming +”\ “}}]}}}”
client.search({ “index”:_index, “type”:_ type, 的体:my_query 强> },function(error,resp){ console.log(“发现错误是:::::”+错误+“resp :::”+ JSON.stringify(resp)); if(error)deferred.reject(error); deferred.resolve(RESP); });