mep*_*son 1 ruby-on-rails elasticsearch searchkick
给定一个使用searchkick索引到elasticsearch的Widget模型:
searchkick word: [:title], highlight: [:title], term_vector: true
Run Code Online (Sandbox Code Playgroud)
我已将这些文件编入索引:
{ title: "work with puppies" }
{ title: "work with sharks" }
{ title: "work with kittens" }
{ title: "shoot lasers at the moon" }
Run Code Online (Sandbox Code Playgroud)
我正在尝试为新的文本做一个"更像这样"(MLT)查询:
"work with lasers"
Run Code Online (Sandbox Code Playgroud)
我的目标是让它击中最后得分最高的文档因为"激光"比"使用"更专业,这在我的文档语料库中很常见.
我试过这个:
Widget.search query: {
mlt: {
like_text: "work with lasers",
min_term_freq: 1,
boost_terms: 5,
analyzer: 'searchkick_search2'
} }
Run Code Online (Sandbox Code Playgroud)
但它让我回到顶部的"工作......"文档,得分最高.
我也尝试过输入一个键/ val {stopwords:['work','with']}然后我得到0结果.
有没有办法让searchkick/elasticsearch给我回复文档,这些文档具有最高分的专业术语和仅与常见术语匹配的淡化文档?
(为了别人的利益回答我自己的问题)
事实证明,除非你有很多文件,否则MLT查询效果不会很好.我把它与大约100万个文档放在一起,上面发布的代码非常适合这个:
search query: {
mlt: {
like_text: str,
min_term_freq: 3,
max_query_terms: 35,
boost_terms: 2,
minimum_should_match: '35%'
}
}
Run Code Online (Sandbox Code Playgroud)
因人而异
| 归档时间: |
|
| 查看次数: |
501 次 |
| 最近记录: |