存在Elasticsearch过滤器和function_score

时间:2017-06-27 13:48:16

标签: elasticsearch

我正在尝试应用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
            }]
        }
    }
}

0 个答案:

没有答案