Consider below Stop field is the timestamp field.
i want to filter data with below condition:
- stop field not exist
- or, stop field value is >= now
I know, i should use must_not but cannot figure out how.
I want to do some scoring on child type and use this score to sort parent, then filter out parent using stop field.
GET indexName/parentType/_search
{
"query": {
"bool": {
"must": [
{
"has_child": {
"type": "child-type",
"score_mode": "max",
"query": {
"function_score": {
"functions": [
{
"script_score": {
"script": {
"file": "score-analytics",
"lang": "expression"
}
}
}
]
}
}
}
},
{
"bool": {
"should": [
{
"range": {
"stop": {
"gte": "now"
}
}
}
]
}
}
]
}
}
}
You need to use exist filter: