简体   繁体   中英

Rails Elasticsearch analyzer mappings defined in model are not reported in elasticsearch

In my Recipe model I have :

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

Then in rails console, I launch Recipe.import . When asking to elasticsearch via curl or Sense GET /recipes-development/_mapping/ , I get

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

I have lost all informations about analyzer. Any idea would be appreciated

Recipe.import之前,您必须执行

Recipe.__elasticsearch__.create_index! force: true

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM