@rule.js/elasticsearch
v0.17.1
Published
Serializable object assertions.
Downloads
25
Maintainers
Readme
Rule.js: Elasticsearch converter
Convert the Rule
object into an elasticsearch query.
const ruleElasticsearch = require('@rule.js/elasticsearch')()
const Rule = require('@rule.js/core').extend({}, {
elasticsearch: ruleElasticsearch
})
Rule()
.or()
.and().equal('name', 'foobar').gt('age', 20).end()
.lt('age', 10)
.end()
.elasticsearch()
Outputs:
{
"bool": {
"must": [
{
"bool": {
"should": [
{
"bool": {
"must": [
{
"term": {
"name": "foobar"
}
},
{
"range": {
"age": {
"gt": 20
}
}
}
]
}
},
{
"range": {
"age": {
"lt": 10
}
}
}
]
}
}
]
}
}