equery
v0.2.0
Published
Query builder for Elasticsearch
Downloads
6
Readme
equery
Query builder for elasticsearch (Node.js / Javascript)
Installation
$ npm install equery
Usage
Building a query
var Query = require('equery');
var query = new Query();
query.toJSON
var result = q.toJSON();
query.sort
query
.sort('followers:desc')
.toJSON();
query.term
query
.term('field', 'value')
.toJSON();
PAgination
query.limit(100);
query.skip(10);
Chain
Queries are chainable:
query
.term('user', 'Kimchy')
.sort('followers:desc')
.limit(100)
.skip(10)
.toJSON();
Filters
A filter can be set on the query using query.filter(filer)
. Multiple calls to query.filter
is equivalent to filter1 AND filter2 AND ...
Filter.Term
query.filter(
Query.Filter.Term('user', 'Kimchy')
)
Filter.Bool
query.filter(
Query.Filter.Bool()
.must(Query.Filter.Term('user', 'Kimchy'))
.mustNot(Query.Filter.Term('user', 'Kimchy'))
)