Skip to content

Instantly share code, notes, and snippets.

@pecavalheiro
Created October 1, 2016 21:31
Show Gist options
  • Select an option

  • Save pecavalheiro/fdb425c312b89413d6393320687b0795 to your computer and use it in GitHub Desktop.

Select an option

Save pecavalheiro/fdb425c312b89413d6393320687b0795 to your computer and use it in GitHub Desktop.
Snippets for Medium Post = Rails + Elasticsearch 101
class Article < ActiveRecord::Base
include Elasticsearch::Model
include Elasticsearch::Model::Callbacks
settings index: { number_of_shards: 1 } do
mappings dynamic: 'false' do
indexes :name
indexes :author
indexes :location, type: :geo_point
indexes :created_at, type: :date
indexes :updated_at, type: :date
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment