在我的食谱模型中,我有:
class Recipe < ActiveRecord::Base
index_name "recipes-#{Rails.env}"
settings do
mappings dynamic: 'false' do
indexes :title, type: 'string', analyzer: 'french'
indexes :description, type: 'string', analyzer: 'french'
end
end
def as_indexed_json(options={})
self.as_json({only: [:title, :description]})
end
然后在Rails控制台中,启动
Recipe.import
。当通过curl或Sense GET /recipes-development/_mapping/
询问elasticsearch时,我得到了{
"recipes-development": {
"mappings": {
"recipe": {
"properties": {
"description": {
"type": "string"
},
"title": {
"type": "string"
}
}
}
}
}
}
我丢失了有关分析仪的所有信息。任何想法将不胜感激
最佳答案
在Recipe.import
之前,您必须执行
Recipe.__elasticsearch__.create_index! force: true
关于ruby-on-rails - 模型中定义的Rails Elasticsearch分析器映射未在Elasticsearch中报告,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30715390/