I followed itay-grudev tutorial.
http://tutorials.pluralsight.com/ruby-ruby-on-rails/elasticsearch-with-ruby-on-rails#settings-and-indexing
It worked as well. and then i wanna scale this demo. Create a new model, Search cross mutil models.
And now i have two Models. Article and Post
In: app/models/concerns/searchable.rb
module Searchable
extend ActiveSupport::Concern
included do
include Elasticsearch::Model
mapping do # ... end
def self.search(query) # ... end
end
end
class Article
include Searchable
end
class Post
include Searchable
end
But i dont know how can i call field of Article and Post in mapping of Searchacle
How about if Article and Post models have same field is "title"
And in controller. i read guide in github offical page. If you wanna search cross multil models you must using syntax:
@results = Elasticsearch::Model.search('fox', [Article, Post]).records.to_a
But i wanna to use search method in Searchable module. How can i change it. I tried to read guide but nowhere clearly so i came here
Sorry for my bad english. Hope everyone can help me. Thanks you so much!