TOPIC: tool: https://github.com/danpaz/bodybuilder An elasticsearch query body builder. Easily build complex queries for elasticsearch with a simple, predictable api.
Does someone know how to make such a query using bodybuilder js?
"query": {
"bool": {
"must": [
{
"bool": {
"should": [
{
"match_phrase": {
"entityType": "CATEGORY"
}
},
{
"match_phrase": {
"entityType": "TAG"
}
},
{
"match_phrase": {
"entityType": "SHOP"
}
}
],
"minimum_should_match": 1
}
}
]
}
}
I tough about this
bodybuilder()
.orQuery('match_phrase', 'entityType', 'CATEGORY')
.orQuery('match_phrase', 'entityType', 'TAG')
.orQuery('match_phrase', 'entityType', 'SHOP')
.build();
but then I get out something like this
{
"query": {
"bool": {
"should": [
{
"match_phrase": {
"entityType": "CATEGORY"
}
},
{
"match_phrase": {
"entityType": "TAG"
}
},
{
"match_phrase": {
"entityType": "SHOP"
}
}
]
}
}
}
which is not same