设置Elasticsearch匹配预定
因此,如果用户使用单词covid
搜索,我想要所有这些结果,其中句子的标题以word covid
开始,然后我想要所有这些项目标题的一部分具有单词covid
。我该如何实现?
我想要更具体的答案,如何使用Searchkick做到这一点。
So if a user search with the word covid
, i want all those results first, where title of the sentence starts with word covid
and then I want all those items where in other parts of the title have the word have word covid
. How can I achieve this?
I want more specific answer, how to do that with searchkick.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果使用默认映射,则可以使用
bool
与两个的查询子句,一个在text>上使用
match> match
/code>,另一个是前缀
.keyword
子字段的查询,如下所示。索引示例文档
搜索查询
搜索结果
注意:首先,拥有
foo bar
得分高得多首先出现If you are using the default mapping, You can use the
bool
query with twoshould
clause, one withmatch
on thetext
and another isprefix
query on.keyword
subfield as shown in below example.Index sample documents
Search query
Search results
Note: first result, having
foo bar
is scored much higher and comes first in the search hits.您甚至可以使用Boost,我想对@Amit代码的修改很少
you can even use boost i guess little modification to @Amit code