3

我试图使用弹性搜索的http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/query-dsl-mlt-query.html#query-dsl-mlt-为相关项目做一个简单的 POC查询

但是我不知道如何使用提升,以便我文档中的重要字段在最终输出中具有更大的权重。另外,我如何才能在更像此查询的情况下应用增强功能,以使最近的文档具有更大的权重。

谢谢。

4

1 回答 1

10

如果文档更像特定文档或者匹配在特定字段上,则实现特定提升的一种方法是,您可以使用多个 mlt 查询并 根据您是否想要“总和”将它们包装在should 子句(bool)/dis_max中/“max of”评分时的逻辑:

使用 dis_max 的示例是:

POST  test_index/_search?explain=true
{
    "fields": [
       "field1",
       "field2"
    ], 
    "query": { 
        "dis_max": {
           "queries": [
               {
                "more_like_this" : {
                    "fields" : ["field1"],
                    "like_text" : "this is  some text",
                    "min_term_freq" : 1,
                    "max_query_terms" : 2,
                    "boost": 20
                }
               },
               {
                "more_like_this" : {
                    "fields" : ["field2"],
                    "like_text" : "this is some other text",
                    "min_term_freq" : 1,
                    "max_query_terms" : 2,
                    "boost": 20
                }
               }
            ]
        }
    }
}
于 2014-11-11T19:38:08.980 回答