Skip to content

Instantly share code, notes, and snippets.

@ericdcobb
Created May 31, 2013 17:51
Show Gist options
  • Save ericdcobb/5686671 to your computer and use it in GitHub Desktop.
Save ericdcobb/5686671 to your computer and use it in GitHub Desktop.
class Test < ActiveRecord::Base
attr_accessible :description, :name, :latitude, :longitude
include Tire::Model::Search
include Tire::Model::Callbacks
index_name "test-app"
tire do
mapping do
indexes :_id, index: :not_analyzed
indexes :name
indexes :description
indexes :location, :type => 'geo_point', :lat_lon => true
end
end
def location
[latitude, longitude].join(',')
end
def to_indexed_json
{
:id => self.id,
:description => self.description,
:name => self.name,
:location => location
}.to_json
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment