Elasticsearch through tire is working fine for me. I wanted a suggestion regarding a problem I'm facing in my code.
mapping do
indexes :id, :index => :not_analyzed
indexes :locality
end
This is a part of my mapping.locality corresponds to a method in the model which is defined as
def locality
self.locality.name
end
The model also
belongs_to :locality
So,you can observe the called method will fall into an infinite loop. I have a limitation that I can't change the name locality in the mapping due to corresponding changes in the frontend which we want to avoid. One alternative is to define a method in the Locality model which gives
def locality_name
self.name
end
I tried to include locality_name method in to_indexed_json and tried mapping this way but failed.
mapping do
indexes :id, :index => :not_analyzed
indexes :locality do
indexes :locality_name
end
end
I want the name of locality to be indexed as "locality" in the result without changing the model Locality.