o-is-elasticsearch
v0.7.1
Published
Serializable object assertions.
Downloads
2
Maintainers
Readme
Object Is: Elasticsearch converter
Convert the oIs object into an elasticsearch query.
const oIsElasticsearch = require('o-is-elasticsearch')
const oIs = require('o-is').extend({
elasticsearch: oIsElasticsearch
})
oIs()
.if()
.equal('name', 'foobar')
.then()
.gt('age', 20)
.else()
.lt('age', '10')
.end()
.elasticsearch()
Outputs:
{
"bool": {
"must": [
{
"bool": {
"should": [
{
"bool": {
"must": [
{
"term": {
"name": "foobar"
}
},
{
"range": {
"age": {
"gt": 20
}
}
}
]
}
},
{
"bool": {
"must": [
{
"range": {
"age": {
"lt": 10
}
}
}
]
}
}
]
}
}
]
}
}