モデル内の特定のフィールドにストップワードのカスタム セットを追加したいと考えています。そのため、そのフィールドにカスタム アナライザーを追加しました。それでも、ストップワードで検索すると、結果が表示されます。私のモデル内のコードは次のとおりです。
settings :analysis => {
:filter => {
:stop_filter => {
:type => "stop",
:stopwords => ["how", "when", "where", "who", "which", "what", "do", "the", "a", "is", "to"]
}
},
:analyzer => {
:my_analyzer => {
:type => "standard",
:filter => "stop_filter",
:tokenizer => "standard"
}
}
} do
mapping do
indexes :id, :type => 'integer', :index => :not_analyzed
indexes :sortable_id, :type => 'integer', :index => :not_analyzed
indexes :summary, :type => 'string', :analyzer => 'my_analyzer'
end
end
def self.search_all(search_string = nil, options = {})
tire.search(:load => true, :page => options[:page] || 1, :per_page => options[:per_page] || 10) do
query {search_string.present? ? string(search_string) : all}
filter :term, {:topics_list_filter => options[:topic_id]} if options[:topic_id]
sort {by options[:sort], options[:order] || 'desc'} if options[:sort].present?
end
end
stopwords
を作成せずに、アナライザーのオプションとして指定することも試しましたstop_filter
。どこが間違っているのかわかりません。