我想向模型中的某个特定字段添加一组自定义停用词。所以我为该领域添加了一个自定义分析器。但是,当我用停用词搜索时,结果显示出来。 我的模型中的代码如下:使用轮胎进行弹性搜索:自定义停用词不起作用
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
尝试。我不知道我哪里出错了。
你的search_string是怎么样的? – imotov
卷曲-X GET “HTTP://本地主机:9200/project_development_192_168_7_13 /问题/ _search从= 0&负载=真页= 1&per_page = 6&大小= 6&漂亮=真?” -d“{ “查询”:{ “QUERY_STRING”:{“查询“:”this is how“}},”filter“:{”term“:{”company_filter“:1}},”size“:6,”from“:0}' - 这是查询被触发。 – deniro