Ruby on rails 升级后,Searchkick无法将索引映射到模型
工作: 环境:Ruby on rails 升级后,Searchkick无法将索引映射到模型,ruby-on-rails,ruby,
elasticsearch,ruby-on-rails-5,searchkick,Ruby On Rails,Ruby,
elasticsearch,Ruby On Rails 5,Searchkick,工作: 环境: 轨道4.1 Searchkick 2.3.2 我将在控制台中执行以下查询: res = Searchkick.search( "Thom", index_name: [Customer.searchkick_index.name, User.searchkick_index.name], match: :word_start, fields: [:first_name, :last_name,
- 轨道4.1
- Searchkick 2.3.2
res = Searchkick.search(
"Thom",
index_name: [Customer.searchkick_index.name, User.searchkick_index.name],
match: :word_start,
fields: [:first_name, :last_name, :name],
limit: 10,
#load: false,
misspellings: {below: 3}
)
res.hits看起来像:
=> [
{"_index"=>"customers_production_20180830135206573", "_type"=>"customer", "_id"=>"162", "_score"=>66.72488},
{"_index"=>"customers_production_20180830135206573", "_type"=>"customer", "_id"=>"547", "_score"=>63.447693},
{"_index"=>"users_production_20170616114857320", "_type"=>"user", "_id"=>"447", "_score"=>59.895348},
{"_index"=>"users_production_20170616114857320", "_type"=>"user", "_id"=>"412", "_score"=>58.541008},
{"_index"=>"users_production_20170616114857320", "_type"=>"user", "_id"=>"338", "_score"=>57.721336},
{"_index"=>"users_production_20170616114857320", "_type"=>"user", "_id"=>"271", "_score"=>42.91793},
{"_index"=>"users_production_20170616114857320", "_type"=>"user", "_id"=>"315", "_score"=>42.91793},
{"_index"=>"users_production_20170616114857320", "_type"=>"user", "_id"=>"201", "_score"=>42.91793}
]
一切正常。我在搜索框中键入我的术语,然后得到结果
res.first
=> #<Customer id: 162, field: yada-yada>
以下是我在模型中的设置:
include Elasticsearch::Model <-- Added after upgrade
include Elasticsearch::Model::Callbacks <-- Added after upgrade
searchkick match: :word_start, searchable: [:name]
scope :search_import, -> {includes(:user)}
谢谢我找到了问题
在文件中:
多模型
使用以下工具跨多个模型进行搜索:
Searchkick.search“牛奶”,型号:[产品,类别]
如此变化:
index_name: [Customer.searchkick_index.name, User.searchkick_index.name]
到
解决了我的问题。我找到了问题
在文件中:
多模型
使用以下工具跨多个模型进行搜索:
Searchkick.search“牛奶”,型号:[产品,类别]
如此变化:
index_name: [Customer.searchkick_index.name, User.searchkick_index.name]
到
解决了我的问题
index_name: [Customer.searchkick_index.name, User.searchkick_index.name]
models: [Customer, User]