settings :analysis => {
:analyzer => {
:my_analyzer => {
"tokenizer" => "lowercase",
# "filter" => ["synonym", "porterStem", "phonetic"]
"filter" => ["synonym", "porterStem"]
}
},
:filter => {
:synonym => {
"type" => "synonym",
"synonyms_path" => "#{Synonym.path}"
}
}
} do
mapping do
indexes :commodity_code
indexes :commodity_name
indexes :long_description, boost: 1,analyzer: 'my_analyzer'
indexes :short_description, boost: 3, analyzer: 'my_analyzer'
indexes :manufacturer_name
indexes :manufacturer_part_number
indexes :increase_relevance_text
indexes :decrease_relevance_text
end
结尾
配置 ElasticSearch,如果最终用户提供的搜索词与 increase_relevance_text 字段中的任何短语完全匹配,则该特定产品的相关性会增加 increase_relevance_points 中的数量。
配置 Elastic Search,如果最终用户提供的搜索词包含 Decrease_Relevance_Text 字段中包含的任何单词或短语(但不需要完全匹配),则该特定产品的相关性会降低在 Decrease_Relevance_Points 中。