This mongo OR statement is a bit confusing translating to an ES DSL. Below is my attempt. Appears to be working, but would like someone more seasoned to stamp it correct or provide insight into how to do it the ES DSL way.
Notice the mongo $ne => 0.00 only exists in the second mongo OR block. How do I apply this condition to only tags match block of my ES DSL?
$filter = [
'$or' => [
[
'created_at' => ['$gt' => $startDate, '$lte' => $endDate],
'transaction_data.transactions.gateway' => 'authorize_net'
],
[
'created_at' => ['$gt' => $startDate, '$lte' => $endDate],
'tags' => ['$regex' => "Option A", '$options' => "i"],
'total_price' => [
'$ne' => '0.00'
]
]
]
];
Mongo equivalent ES DSL?
GET orders/_search
{
"query": {
"bool": {
"must_not": [
{
"term": {
"total_price": {
"value": "0.00"
}
}
}
],
"should": [
{
"term": {
"transaction_data.transactions.gateway": {
"value": "authorize_net"
}
}
},
{
"match": {
"tags": "Option A"
}
}
],
"filter": [
{
"range": {
"created_at": {
"gt": "2018-02-16",
"lte": "2018-02-28"
}
}
}
],
"minimum_should_match": 1
}
}
}