Rails-elasticsearch: 无法执行 table 的自定义映射内容

Rails-elasticsearch: unable to perform custom mapping content of the table

我正在尝试为我的模型创建一个到 elasticsearch 服务器的自定义索引。不知何故,我只能呈现一个结构(选定的列)但没有记录。

我的模特:

require 'elasticsearch/model'

class Lead < ApplicationRecord
  include Elasticsearch::Model
  include Elasticsearch::Model::Callbacks

   mappings dynamic: false do
      indexes :id, type: 'keyword'
      indexes :lead_status, type: 'keyword'
      indexes :country
      indexes :city
      indexes :title
      indexes :description
      indexes :contact_person
    end
end

然后我尝试从 rails 控制台创建索引:

2.5.1 :004 > Lead.__elasticsearch__.create_index!(force:true)
2018-11-26 04:19:55 +0100: DELETE http://localhost:9200/leads [status:404, request:0.034s, query:N/A]
2018-11-26 04:19:55 +0100: < {"error":{"root_cause":[{"type":"index_not_found_exception","reason":"no such index","resource.type":"index_or_alias","resource.id":"leads","index_uuid":"_na_","index":"leads"}],"type":"index_not_found_exception","reason":"no such index","resource.type":"index_or_alias","resource.id":"leads","index_uuid":"_na_","index":"leads"},"status":404}
2018-11-26 04:19:55 +0100: [404] {"error":{"root_cause":[{"type":"index_not_found_exception","reason":"no such index","resource.type":"index_or_alias","resource.id":"leads","index_uuid":"_na_","index":"leads"}],"type":"index_not_found_exception","reason":"no such index","resource.type":"index_or_alias","resource.id":"leads","index_uuid":"_na_","index":"leads"},"status":404}
[!!!] Index does not exist (Elasticsearch::Transport::Transport::Errors::NotFound)
2018-11-26 04:19:55 +0100: HEAD http://localhost:9200/leads [status:404, request:0.007s, query:N/A]
2018-11-26 04:19:55 +0100: < 
2018-11-26 04:19:55 +0100: [404] 
2018-11-26 04:19:56 +0100: PUT http://localhost:9200/leads [status:200, request:0.707s, query:n/a]
2018-11-26 04:19:56 +0100: > {"settings":{},"mappings":{"_doc":{"dynamic":false,"properties":{"id":{"type":"keyword"},"lead_status":{"type":"keyword"},"country":{"type":"text"},"city":{"type":"text"},"title":{"type":"text"},"description":{"type":"text"},"contact_person":{"type":"text"}}}}}
2018-11-26 04:19:56 +0100: < {"acknowledged":true,"shards_acknowledged":true,"index":"leads"}
 => {"acknowledged"=>true, "shards_acknowledged"=>true, "index"=>"leads"}

之后,在我位于 /leads 的本地 elasticsearch 服务器上,我可以看到我的自定义结构,但没有任何记录。我该如何解决这个问题?

Rails版本:5.2.1 弹性搜索:6.4.3 elasticsearch-model/rails 宝石:6.0.0

我对这类东西使用 es-elasticity。但是从 elasticsearch 的输出来看,它只是在创建索引,您必须为对象建立索引以便它们显示在 elasticsearch 中。

从 gandering 文档来看,您似乎可以通过执行 Lead.import

来导入