Created
August 23, 2015 14:48
-
-
Save skateman/e2a6025be5713bf8b8e6 to your computer and use it in GitHub Desktop.
ElasticSearch integration to ActiveRecord
This file contains 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
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