# Full-text-search Mutil Models Active Record Rails

**URL:** <https://discuss.elastic.co/t/full-text-search-mutil-models-active-record-rails/62089>\
**Category:** Elasticsearch\
**Created:** [October 3, 2016, 4:16pm UTC](https://discuss.elastic.co/t/full-text-search-mutil-models-active-record-rails/62089 "2016-10-03T16:16:45Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![loha](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/loha/32/12261_2.png) [@loha](https://discuss.elastic.co/u/loha)\
**Post date:** [October 3, 2016, 4:16pm UTC](https://discuss.elastic.co/t/full-text-search-mutil-models-active-record-rails/62089/1 "2016-10-03T16:16:45Z")

</div>

I followed itay-grudev tutorial.  
[http://tutorials.pluralsight.com/ruby-ruby-on-rails/elasticsearch-with-ruby-on-rails#settings-and-indexing](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!

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [July 5, 2017, 10:15pm UTC](https://discuss.elastic.co/t/full-text-search-mutil-models-active-record-rails/62089/2 "2017-07-05T22:15:22Z")

</div>

Closed on July 5, 2017, 10:15pm UTC


