ESQ (Elasticsearch Query)
I wanted an easy way to build elasticsearch queries without having to writing lots and lots of code just for the structure of the query. For that reason I created ESQ, a very simple but powerful tool that will do all of the object creation for you.
Download
npm install esq
or bower intall esq
Quick Example
Example
var ESQ = ;var esq = ; esq;esq; var query = esq;
Generates
In the browser
Documentation
esq.getQuery();
This will return the query at the current stage.
Example
esq;var query = esq;
Generates
esq.query(str, ..., str, value);
You can pass this function as many strings as you want and you'll receive a nested object with the arguments as keys. The final argument should always be the object you want to assign to the second to last argument. This function will always return the query at its current state.
Example
esq;
Generates
Array Arguments
The function also allows you to pass in an argument as an array (e.g. ['must']
). This tells the function that you want that key to be an array and so it'll push the following arguments into the array.
Example
esq;
Generates
Tests
This module is fully tested, run the tests using mocha
.