0

When I tried to create query like

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;

I am getting the following error:

[query_parsing_exception] [bool] query does not support [must]

1 Answer 1

3

I have solved this by creating complete body tag as dynamic query string and passed this variable to the elasticsearch query. ex: var my_query = "{\"query\": {\"bool\":{\"must\": [{ \"match\": { \"techskills.programming\":\"" + programming + "\"} }]}}}"

client.search({ "index": _index, "type": _type, body:my_query },function (error,resp) { console.log("Found error is ::::: "+error + " resp::: "+JSON.stringify(resp)); if(error) deferred.reject(error); deferred.resolve(resp); });

Sign up to request clarification or add additional context in comments.

1 Comment

Thank you so much, i spend one whole afternoon trying to achieve that lol

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.