除非您使条件更严格,否则Elasticsearch MLT查询不会返回任何结果

时间:2019-01-11 00:57:32

标签: elasticsearch morelikethis

我针对标题字段中带有“三”的文档的_explain端点发布以下查询

{
"query": {
    "bool": {
        "must": [
            {
                "bool": {
                    "should": [
                        {
                            "more_like_this": {
                                "min_doc_freq": 1,
                                "fields": [
                                    "title"
                                ],
                                "max_query_terms": 10,
                                "like": "Three Reasons Spice Girls Will Reunite (And Three Why They Won't)",
                                "min_term_freq": 1
                            }
                        },
                        {
                            "more_like_this": {
                                "min_doc_freq": 1,
                                "fields": [
                                    "description"
                                ],
                                "max_query_terms": 10,
                                "like": "Three Reasons Spice Girls Will Reunite (And Three Why They Won't)",
                                "min_term_freq": 1
                            }
                        }
                    ]
                }
            }
        ]
    }
}

}

我得到的答复/解释:

"matched": false,
"explanation": {
    "value": 0,
    "description": "Failure to meet condition(s) of required/prohibited clause(s)",
    "details": [
        {
            "value": 0,
            "description": "no match on required clause (((title:girl title:and title:why title:will title:thei title:won title:reason title:reunit title:spice title:three)~3) ((description:and description:why description:thei description:won description:girl description:will description:reason description:spice description:reunit description:three)~3))",
            "details": [
                {
                    "value": 0,
                    "description": "No matching clauses",
                    "details": []
                }
            ]
        },
        {
            "value": 0,
            "description": "match on required clause, product of:",
            "details": [
                {
                    "value": 0,
                    "description": "# clause",
                    "details": []
                },
                {
                    "value": 0.023566995,
                    "description": "_type:media, product of:",
                    "details": [
                        {
                            "value": 1,
                            "description": "boost",
                            "details": []
                        },
                        {
                            "value": 0.023566995,
                            "description": "queryNorm",
                            "details": []
                        }
                    ]
                }
            ]
        }
    ]
}

但是,如果我将min_term_freq的值从1增加到2,则会得到一个匹配项。同样,如果我从类似的查询中删除了几个字词,例如“三个原因(三个)(三个原因)”,则我得到匹配。

为什么这样会有意义,那就是随着条件变得越来越严格(min_term_freq增加)而匹配

1 个答案:

答案 0 :(得分:0)

minimum_should_match默认为3,我没有达到标准。通过将默认值更新为1,我得到了匹配。