I've been messing around with this for a while but can't get it right. I've tried several different ways of displaying this query. For example, I've made each param inside of bool a key instead of an array element. As it is now it's an array element. Either way ES doesn't seem to like it. What would be the proper format for the following query?
What it's supposed to do:
This is PHP. The should query is either in between two dates and must have the status ended OR it must start at one date and the status cannot be ended.
[
'index' => 'quotes',
'type' => 'title',
'body' => [
'query' => [
"function_score" => [
'query' => [
'bool' => [
'filter' => [
["range" => ["number_of_quotes" => ["gt" => 0]]],
["exists" => ["field" => "vote-average"]],
["exists" =>["field" => "first-air-date"]],
["exists" =>["field" => "last-air-date"]],
],
'should' => [
['bool' => [
["range" => ["first-air-date" => [
"gte" => "$begin",
"format" => "yyyy"
],
["last-air-date" => [
"lte" => $begin,
"format" => "yyyy"
]],
]],
["must" => [
"match" => [
"status" => "Ended"
]
]
]],
],
['bool' => [
["range" => ["first-air-date" => [
"gte" => "$begin",
"format" => "yyyy"
]]],
["must_not" => [
"match" => [
"status" => "Ended"
]
]
]],
]]],
]
],
],
],
"from" => (int) $skip,
"size" => (int) $take,
];