2015-06-08 78 views
1

不報在我的食譜模型我有:在模型中定義的Rails Elasticsearch分析儀映射在elasticsearch

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 

然後在鐵軌控制檯,我啓動Recipe.import。當詢問通過捲曲或感GET /recipes-development/_mapping/到elasticsearch,我得到

{ 
    "recipes-development": { 
     "mappings": { 
     "recipe": { 
      "properties": { 
       "description": { 
        "type": "string" 
       }, 
       "title": { 
        "type": "string" 
       } 
      } 
     } 
     } 
    } 
} 

我已經失去了對分析所有信息。任何想法,將不勝感激

回答

0

Recipe.import之前,你必須執行

Recipe.__elasticsearch__.create_index! force: true