我正在使用ElasticSearch和Tire執行一些基本的搜索功能,但是雪球干擾分析器的基本配置讓我難住了。我幾乎從以下GitHub的頁面代碼示例:https://github.com/karmi/tire使用輪胎庫進行干擾
下面是一個Ruby示例文件(紅寶石1.9.3,輪胎25年8月1日):
require 'tire'
Tire.index 'videos' do
delete
create :mappings => {
:video => {
:properties => {
:code => { :type => 'string' },
:description => { :type => 'string', :analyzer => 'snowball' }
}
}
}
end
videos = [
{ :code => '1', :description => "some fight video" },
{ :code => '2', :description => "a fighting video" }
]
Tire.index 'videos' do
import videos
refresh
end
s = Tire.search 'videos' do
query do
string 'description:fight'
end
end
s.results.each do |document|
puts "* #{document.code} - #{document.description}"
end
我本來期望這產生在比賽中都有記錄,因爲戰鬥和戰鬥具有相同的主幹。然而,它只返回的第一條記錄:
* 1 - some fight video
這表明默認分析儀正在使用,而不是一個,我配置。
我知道在查詢字符串中傳遞實際字段(ElasticSearch mapping doesn't work)並已成功運行此代碼,因此我的ElasticSearch安裝看起來很好。
我需要做什麼來改變輪胎的這個查詢(即我如何才能制止在這裏工作)返回兩個記錄?