Skip to content

Instantly share code, notes, and snippets.

@skateman
Created August 23, 2015 14:48
Show Gist options
  • Save skateman/e2a6025be5713bf8b8e6 to your computer and use it in GitHub Desktop.
Save skateman/e2a6025be5713bf8b8e6 to your computer and use it in GitHub Desktop.
ElasticSearch integration to ActiveRecord
module FulltextSearchable
extend ActiveSupport::Concern
included do
include Elasticsearch::Model
include Elasticsearch::Model::Callbacks
end
module ClassMethods
# Use this method to specify which columns you want to index
def index_only(*columns)
define_method(:as_indexed_json) do |_|
as_json(:only => columns)
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment