Skip to content

Instantly share code, notes, and snippets.

@jraczak
Created March 3, 2015 15:54
Show Gist options
  • Save jraczak/825300c23c3d4362708e to your computer and use it in GitHub Desktop.
Save jraczak/825300c23c3d4362708e to your computer and use it in GitHub Desktop.
### elasticsearch_searchable.rb ###
require 'active_support/concern'
module ElasticsearchSearchable
extend ActiveSupport::Concern
included do
require 'elasticsearch/model'
include Elasticsearch::Model
include Elasticsearch::Model::Indexing
mapping do
#write some code
end
def self.search(query)
#write some more code
end
end
end
### user.rb ###
# Elasticsearch configuration
include ElasticsearchSearchable
# index_name "users" <-- This value is inferred automatically by the model name
settings index: { number_of_shards: 1 }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment