2

I am using the Elasticsearch-rails gem in my application. I need my index mapping in the model to look like the JSON you see below (shortened only to include only relevant pieces). The part I don't understand relates to "name." How would that mapping be setup if this is what I need it to look like?

JSON Mapping I want to Rails model to output

{  
   "recipes":{  
      "mappings":{  
         "list":{  
            "dynamic":"false",
            "properties":{  
               "creator_name":{  
                  "type":"string"
               },
               "name":{  
                  "type":"string",
                  "fields":{  
                     "raw":{  
                        "type":"string",
                        "index":"not_analyzed"
                     }
                  }
               },
               "permalink":{  
                  "type":"string"
               },
               "user_id":{  
                  "type":"string"
               }
            }
         }
      }
   }
}

Current Rails model mapping

  settings :index => { :number_of_shards => 1  } do
    mapping :dynamic => 'false' do
      indexes :user_id, :type => 'string'
      indexes :permalink, :type => 'string'
      indexes :creator_name, :type => 'string'
      indexes :name, :type => 'string' # How do i make this match the json?
    end
  end

How do I set indexing for 'name' in the model to look like the JSON?

Thanks a lot!

aressidi
  • 680
  • 1
  • 10
  • 26
  • 1
    What if you just extend it to `indexes :name, :type => 'string', :fields => { :raw => { :type => 'string', :index => 'not_analyzed } }`? – Roman Jul 13 '15 at 10:26

0 Answers0