此查询效果很好,但返回的结果太多了。我想添加boost函数,但我不知道正确的语法。
$data_string = '{
"from" : 0, "size" : 100,
"sort" : [
{ "date" : {"order" : "desc"} }
],
"query": {
"more_like_this_field" : {
"thread.title" : {
"like_text" : "this is a test",
"min_word_len" : 4,
"min_term_freq" : 1,
"min_doc_freq" : 1
}
}
}
}';
答案 0 :(得分:1)
找到解决方案。看起来像使用fuzzy_like_this_field和min_similarity是可行的方法。
$data_string = '{
"from" : 0, "size" : 100,
"query": {
"fuzzy_like_this_field" : {
"thread.title" : {
"like_text" : "this is a test",
"min_similarity": 0.9
}
}
}
}';
答案 1 :(得分:0)
根据docs,您只需将其添加到其他参数:
...
"thread.title" : {
"like_text" : "this is a test",
"min_word_len" : 4,
"min_term_freq" : 1,
"min_doc_freq" : 1,
"boost": 1.0
}
...
此外,如果您的文档太多,您也可以尝试增加min_term_freq
和min_doc_freq
。