Created
          March 3, 2015 15:54 
        
      - 
      
- 
        Save jraczak/825300c23c3d4362708e 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
    
  
  
    
  | ### 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