タイヤで弾力的な検索をしているプロジェクトを継承しています。伸縮性のある検索とタイヤを使用してアクセントを無視する
検索は機能していますが、アクセント記号で表示されます。 「this」を検索すると、たとえば「thís」と「thiš」を返す必要があります。私は、このタイヤのドキュメントを読んでいる
:
と同様にhttp://karmi.github.com/tire/:http://railscasts.com/episodes/306-elasticsearch-part-1?view=asciicast弾性検索のオプションのほとんどはタイヤで利用可能であることを述べて
。アクセントを無視に関する検索
は、asciifoldingが来るまま、しかし弾性検索はちょうどこのことについて言いたいことがあります。
http://www.elasticsearch.org/guide/reference/index-modules/analysis/asciifolding-tokenfilter.html
さらに私は、このようなフィルタ/アクセント/などについていくつかのことを見つけました:
https://github.com/elasticsearch/elasticsearch/issues/890
https://gist.github.com/2142635
しかし、彼らはすべての裸弾性検索オプションを使用しています。
ルビコードでasciifoldingフィルタを使用しようとすると、 "asciifolding"に対してフィルタが定義されていないというエラーが表示されます。
これは私のコードで行われている検索の邪魔です。アクセントのない検索を行うにはどうすればよいですか?それは浮き彫りですか?もしそうなら、私はここでそれをどう宣言しますか?
result = tire.search(:load => true,page: params[:page], per_page: params[:per_page]) do
query { string "#{params[:term]}", :default_operator => 'and' } if params[:term].present?
filter :missing, :field => 'original_media_id' #see above
#asciifolding?
sort { by :updated_at, :desc } if params[:term].present?
facet 'files' do
terms 'indexed_files.file.id'
end
end
EDIT:またはマッピング/インデックス作成で行う必要がありますか?そしてインデクサを再実行します。フィルタ=>「asciifolding」をインデックスの一部に、それは仕事(や任意のエラー出力を生成)していないようでした:ここで私が入れて試したマッピングは、だ
tire.mapping do
indexes :id, :index => :not_analyzed
indexes :name, :filter => "asciifolding"
indexes :description, :filter => "asciifolding"
indexes :created_at, :type => 'date'
indexes :updated_at, :type => 'date'
indexes :file_type
indexes :indexed_files, :type => 'object' do
indexes :file, :type => 'object',
:properties => {
:title => {
:type => "multi_field",
:fields => {
:raw => { :type => 'string', :index => 'not_analyzed'},
:title => { :type => 'string', :filter => "asciifolding" }
}
},
:description => { :type => "string", :filter => "asciifolding" }
}
end
end