Rails elasticsearch映射被忽略

IvRRimUm

因此,我已经尝试使此功能工作了几个小时,似乎没有任何效果。

mappings在模型中定义了:

  settings do
    mappings dynamic: false do
      indexes :title, type: 'text'
      indexes :description, type: 'text'
      indexes :user, type: 'text' do
        indexes :name, type: 'text'
      end
    end
  end

但是当我这样做时:

Podcast.__elasticsearch__.delete_index! force: true Podcast.__elasticsearch__.create_index! force: true Podcast.__elasticsearch__.import force: true

并访问: http://localhost:9200/podcasts/_search?pretty=true&q=*:*&size=1000

我看到所有模型数据都注入了索引(我只需要标题,描述和用户名)。

这里有什么问题?

IvRRimUm

索引时,rails-ealsticsearch使用as_indexed_json这是我的示例:

def as_indexed_json(options = {})
  as_json(include: {
    user: {
      only: [
        :id,
        :slug, 
        :name
      ]
    }
  })
end

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章