I made elastic.js build dynamic query like this:
{
"size": 15,
"query": {
"bool": {
"must": [
{ "term": { "tag": { "term": "rocket" } } },
{ "term": { "name": { "term": "space" } } }
],
"should": [
{ "wildcard": { "place": { "value": "Moo*" } } }
]
}
}
}
Elastic.js code for this is ( Translator ):
ejs.Request()
.size(15)
.query(
ejs.BoolQuery()
.must(ejs.TermQuery('tag', 'rocket'))
.must(ejs.TermQuery('name', 'space'))
.should(ejs.WildcardQuery('place', 'Moo*'))
)
It works great, I am happy and I would like it to be like that. But I realized that I need to add an option to perform this query with OR
condition, instead of AND
as is now.
It should find documents that match any of provided conditions.
And that task leaves me with no clues (even about DSL that will complete this purpose).
I have looked at OrFilter but I have no idea on how to use it right (especially with elasticJS). Any solid source of information on elastic/js will be greatly appreciated