Skip to content
This repository has been archived by the owner on Jun 30, 2018. It is now read-only.

Using MultiSearch

Jeremy Woertink edited this page Sep 25, 2013 · 1 revision

Using the Tire multisearch method.

You can search across multiple indexes, with their own sorting, queries, filters, etc...

@search = Tire.multi_search do |ms|
  # Search books
  ms.search :books, index: Book.index_name do |s|
    s.query { string 'title:Harry Potter' }
    s.sort { by :isbn, :desc }
  end
  
  # Search Videos
  ms.search :videos, index: Video.index_name do |s|
    s.query { string 'title:Total Recall' }
    s.sort { by :rotten_score, :asc }
  end
end

@search.results[:books]
@search.results[:videos]