Applying range filter on a boolean field
In a search query, I am trying to get product records that are either not suppressed or if suppressed then the suppression range is either before current time or after current time. Here is the query that I came up with, which certainly have some issue. I could not find any relevant article on this/similar issue thus posting it here to get community/Elastic team's help:
{
"_source": {
"includes": [
"ProductId",
"Active",
"ActiveFrom",
"ActiveTo",
"Suppressed",
"SuppressedFrom",
"SuppressedTo"
]
},
"size": 1000,
"query": {
"constant_score": {
"filter": {
"bool": {
"must": [
{
"match": {
"Active": true
}
},
{
"range": {
"ActiveFrom": {
"lte": **CurrentTime**
}
}
},
{
"range": {
"ActiveTo": {
"gte": **CurrentTime**
}
}
},
{
"match": {
"Suppressed": false
}
},
{
"match": {
"Suppressed": true
},
"range": {
"SuppressedFrom": {
"gte": **CurrentTime**
}
}
},
{
"match": {
"Suppressed": true
},
"range": {
"SuppressedTo": {
"lte": **CurrentTime**
}
}
}
]
}
}
}
}
}
I am getting parsing exception [match] malformed query, expected [END_OBJECT] but found [FIELD_NAME] for the use of range clause after match clause where Suppressed is true.
Thanks,
T