Elasticsearch Rails as_indexed_json 与映射

Elasticsearch Rails as_indexed_json vs mappings

我正在使用 Elasticsearch Rails gem 并且我在我的模型中使用了两个东西:

def as_indexed_json

end

settings index: { number_of_shards: 1 } do
  mapping dynamic: 'false' do
    indexes :id
    indexes :customer do                                                                                                                                                                                                                          
      indexes :first_name
    end
  end
end 

我已经阅读了文档,但我不明白其中每一个的用途是什么。我想弄清楚的是这些是用于搜索索引数据还是用于创建索引数据?

as_indexed_json方法用于覆盖将哪些数据发送到ES进行索引。 ES如何索引你发送的数据由第二部分配置。

要在索引数据中使用 ES 进行搜索,您必须执行 _query

如果您需要更多信息,请随时询问