Glo*_*ior 2 elasticsearch morelikethis
我试图使用elasticsearch的http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/query-dsl-mlt-query.html#query-dsl-mlt-为相关项目做一个简单的POC .查询,
但我没有得到如何使用增强功能,以便我的文档中的重要字段在最终输出中承载更多权重.另外,我如何应用更多像此查询的提升,以便最近的文档更重要.
谢谢.
如果文档更像是特定文档或者匹配是在特定字段上,那么实现特定提升的一种方法是,您可以使用多个mlt查询并 根据您是否需要"sum of" 将它们包装在should子句(bool)/ dis_max中得分时/"最大"逻辑:
使用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
}
}
]
}
}
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
3785 次 |
| 最近记录: |