In SQL:
select * from my_index where type in ('a', 'b') and (type <> 'a' or value_field = 'sth')
Filter by field value_field
when type
is 'a'. Using script:
{
"query": {
"bool": {
"filter": [
{
"terms": {
"type": [
"a",
"b"
]
}
},
{
"script": {
"script": {
"source": "return doc['type'].value != 'a' || doc['value_field'].value == params['val']",
"params": {
"val": "sth"
}
}
}
}
]
}
}
Any other way to do this without script?