use*_*706 5 ruby-on-rails elasticsearch searchkick
我有一个 Campaign 模型,这就是我的自定义映射的样子:
searchkick mappings: {
campaign: {
properties: {
title: {type: "string", analyzer: "snowball"},
deal_title: {type: "string", analyzer: "snowball"},
description: {type: "string", analyzer: "snowball"}
}
}
}
Run Code Online (Sandbox Code Playgroud)
当我重新索引竞选文件时
c = Campaign.search "this is"
Run Code Online (Sandbox Code Playgroud)
我收到以下错误:
Searchkick::InvalidQueryError: [400] {
"error":{
"root_cause":[
{
"type":"query_parsing_exception",
"reason":"[match] analyzer [searchkick_search] not found",
"index":"campaigns_development_20160205130806185",
"line":1,
"col":96
}
],
"type":"search_phase_execution_exception",
"reason":"all shards failed",
"phase":"query",
"grouped":true,
"failed_shards":[
{
"shard":0,
"index":"campaigns_development_20160205130806185",
"node":"kiTXKzIEQjuI9UNDzXZ1DA",
"reason":{
"type":"query_parsing_exception",
"reason":"[match] analyzer [searchkick_search] not found",
"index":"campaigns_development_20160205130806185",
"line":1,
"col":96
}
}
]
},
"status":400
}
Run Code Online (Sandbox Code Playgroud)
此外,当我将 merge_mappings: true 添加到现有映射时,
searchkick merge_mappings: true, mappings: {
campaign: {
properties: {
title: {type: "string", analyzer: "snowball"},
deal_title: {type: "string", analyzer: "snowball"},
description: {type: "string", analyzer: "snowball"}
}
}
}
Run Code Online (Sandbox Code Playgroud)
和
search c = Campaign.search "this is"
Run Code Online (Sandbox Code Playgroud)
,我得到的结果是在 title/deal_title/description 中包含“这是”字样的广告系列。
但是由于我使用的是雪球分析器,这些常见的停用词不应该被编入索引,因此返回 0 结果。
同样在映射更改的第二种情况下,它没有给出错误。所以我认为 searchkick 不能识别滚雪球分析器,因为我做了 merge_mappings: true,它必须使用默认分析器进行索引。这就是为什么它不会给出任何错误。
所以问题真的是:我展示的第一次映射有什么问题,或者 searchkick 没有识别雪球(或任何与此相关的分析器,用停止分析器尝试过同样的事情)分析器?
| 归档时间: |
|
| 查看次数: |
1265 次 |
| 最近记录: |