Elastic Search config

I have a model and inserted some data for that in database already. Now I want to configure elasticsearch with that model. When I try to search I could not find any record. I expect 2 records to be returned. I am using tire gem. Following the code sample:

class MyModel < ActiveRecord::Base

attr_accessible :name

include Tire::Model::Search

include Tire::Model::Callbacks

def self.search(params)

#tried update_index but shows undefined variable

#to map with name which is already in database. tire.mapping do

indexes :name, :type => ‘string’, :index => :not_analyzed

end

tire.search(load: true) do

query {string params[:query]} if params[:query].present?

end

end

end

I am calling in controller like this:

MyModel.search(params) # where params[:query] = “Anand Soni”

I want to know that Would tire load the datas which are already inserted in database?

What I am missing in MyModel? I have seen railscast first and find that it will index that data when it would create.

Thanks,

Anand Soni