多字部分搜索

时间:2017-05-07 03:45:27

标签: elasticsearch

我对弹性搜索很新。 想知道如何搜索部分多字搜索。 \

代表: 我的文件 { “标题”:“哈利搬运工” } 我需要使用以下字符串搜索此文档 1.)har por 与sql查询相同(从书中选择*,其中标题为'%har%'或标题为'%por%')

2 个答案:

答案 0 :(得分:0)

使用completion suggester将提供您想要的大多数功能。它会找到以任意字符串开头的单词,例如“har”或“por”。

Check out this question有关如何设置完成建议器的完整示例。

正如in the documentation所述,您可以通过创建分析器并将选项Document Model设置为{{1}来实现多字搜索(即通过搜索“por”返回“harry horter”) }}

after_create :create_emp_documents

def create_emp_documents
 Employeee.all.each do |employee|
   self.empdocuments.create(employee_id: employee.id)
 end
end

答案 1 :(得分:0)

请参阅:Edge NGram Tokenizer

这有助于部分多词搜索(类似于自动完成建议)。希望这会有所帮助!

相关问题