小编Dom*_*ner的帖子

Searchkick:无法找到原始记录时删除文档

以另一个问题为例

product = Product.find(10) 
   `raise_record_not_found_exception!'
product.nil?
=> true

product = Product.search "*", where: {id: 10}, load: false
product.count
=> 1
Run Code Online (Sandbox Code Playgroud)

如何在没有干净擦拭的情况下取出文档?

谢谢

ruby-on-rails elasticsearch kibana searchkick

2
推荐指数
1
解决办法
1092
查看次数

升级后 Searchkick 无法将索引映射到模型

工作环境:

  • 轨道 4.1
  • 搜索踢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}
        )
Run Code Online (Sandbox Code Playgroud)

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}
]
Run Code Online (Sandbox Code Playgroud)

一切都按预期进行。我在搜索框中输入我的术语并得到结果。

res.first
 => #<Customer id: 162, field: yada-yada>
Run Code Online (Sandbox Code Playgroud)

升级后为:

  • 轨道 5.2
  • 搜索踢4.4.1

我做了同样的查询,我得到以下回击

资源点击数:

[
{"_index"=>"customers_staging_20200920170910290", "_type"=>"_doc", …
Run Code Online (Sandbox Code Playgroud)

ruby ruby-on-rails elasticsearch searchkick ruby-on-rails-5

1
推荐指数
1
解决办法
850
查看次数