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中的数量。
配置弹性搜索,以便如果最终用户提供的搜索词包含Decrease_Relevance_Text字段中包含的任何单词或短语(但不一定是完全匹配),则该特定产品的相关性会降低通过Decrease_Relevance_Points中的金额。
答案 0 :(得分:0)
这是我得到的解决方案
应该
custom_score :script => "_score+doc['increase_relevance_points'].value" do
boolean do
should { match :increase_relevance_text, term}
end
end
end