我正在尝试应用function_score
查询,以及在Elasticsearch 5.4.1中仅返回特定字段不为空(exists
查询)的结果的过滤器。< / p>
评分函数按预期工作,但我不确定如何在exists
的上下文中应用function_score
查询。
示例:
{
"query": {
"function_score": {
"query": {
"filter": {
"bool": {
"must": {
"exists": {
"field": "name_of_field"
}
}
}
},
"dis_max": {
"queries": [{
"multi_match": {
"query": "term",
"fields": ["name^3", "other_names"]
}
}, {
"match_phrase": {
"known_as": "term"
}
}]
}
},
"functions": [{
"filter": {
"match_phrase_prefix": {
"known_as": "term"
}
},
"weight": 200
}, {
"filter": {
"multi_match": {
"query": "term",
"fields": ["name^3", "other_names"],
"operator": "and"
}
},
"weight": 10
}]
}
}
}