[Rails] 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
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
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home