es-query-builder
build elasticsearch queries the sane way
Motivation
the elasticsearch json query syntax is painful
Setup
es-query-builder
expects both ES_URL
and ES_INDEX
environment variables to be definied
so you may have a config file that looks something like:
export ES_INDEX=events
export ES_URL=https://mysearch:9200
Usage
var Query = require('es-query-builder')
var q = new Query
q.size(10)
q.queryString('event.type:foo')
q.range('timestamp', 1467817775660, 1467817785860)
q.agg('min', 'min_timestamp', 'timestamp')
q.agg('max', 'max_timestamp', 'timestamp')
q.fetch()
q.fetch(function(err, res) {
})