strongman
a node module for composing elasticsearch queries, inspired by bodybuilder.js
note: this is still a work in progress and is not suitable for use in production
Installing
$ npm install --save strongman
Getting Started
import { expect } from 'chai'
import { bool, term, exists } from 'strongman'
const query = bool().filter(
term('published', true),
bool().should(
term('whitelist', 'foo'),
bool().must(
exists('blacklist')
).mustNot(
term('blacklist', 'foo')
)
).minimumShouldMatch(1)
)
expect(query.get()).to.deep.equal({
bool: {
filter: [{
term: {
published: true
}
}, {
bool: {
should: [{
term: {
whitelist: 'foo'
}
}, {
bool: {
must: {
exists: {
field: 'blacklist'
}
},
must_not: {
term: {
blacklist: 'foo'
}
}
}
}],
minimum_should_match: 1
}
}]
}
})
Queries
coming soon*
Testing
$ npm test
Contributing
- Fork it
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create new Pull Request
License
Copyright (c) 2017 Chris Ludden.
Licensed under the MIT license.