我试图使用elasticsearch' s http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/query-dsl-mlt-query.html#query-dsl-mlt-query,
为相关项目做一个简单的POC但我没有得到如何使用助推器,以便我的文档中的重要字段在最终输出中承担更多的重量。另外,我如何在这个查询中应用提升,以便最近的文档更重要。
感谢。
答案 0 :(得分:7)
如果文档更像某个特定文档,或者如果匹配位于特定字段上,则可以使用多个mlt查询并将其包装在 should子句(bool)/ dis_max中,从而实现特定提升的一种方法 根据您在得分时是否需要“sum of”/“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
}
}
]
}
}
}