Created
May 31, 2013 17:51
-
-
Save ericdcobb/5686671 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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