How to build dynamic query of elasticsearch. which will execute on nodejs

When i tried to create query like on nodejs like

var my_query = new Object("[{ "match": { "techskills.programming":"+ programming+" } }]");

var deferred = Q.defer();{
"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);
return deferred.promise;


I am getting [query_parsing_exception] [bool] query does not support [must] error.
How can i create dynamic query in elasticsearch so that i can append more criteria in query on runtime.


even though there are some helpers on NPM (just search for it), I think the easiest way is to create the JSON yourself and append to that JSON object, as mentioned in the docs

Also if you show the HTTP query it might be easier to debug issues. See the tracer logger type