考虑下面的停止字段是时间戳字段。
我想过滤具有以下条件的数据:
- 停止字段不存在
- 或者,停止字段值现在 >=
我知道,我应该使用 must_not 但不知道如何使用。
我想对子类型进行一些评分并使用此分数对父级进行排序,然后使用停止字段过滤掉父级。
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"
}
}
}
]
}
}
]
}
}
}