Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Implementing Universal search in rails 4

I have a rails 4 application with number of models and view pages. The application layout of my application contains a search bar. But it is inactive as of now. The purpose of search bar is to allow user to search through all the models for the keyword(s) entered, basically making it a global search. Is there any gem which does universal search? Or it has to be done manually through sql queries? I could see way to implement search for a specific model on its view page. But I want it to search through all the models at once. How should I go about it?

like image 867
Vivek Tripathi Avatar asked Mar 11 '15 05:03

Vivek Tripathi


2 Answers

I think the best way in your case is to use ElasticSearch. A neat integration gem is provided here. Links to documentation are provided on that page.

like image 123
Almaron Avatar answered Sep 27 '22 21:09

Almaron


One of the good approach for it will be to use gem 'searchkick' which uses elasticsearch.

Resources for Searchkick: https://github.com/ankane/searchkick https://github.com/ankane/searchkick#advanced

like image 42
sansarp Avatar answered Sep 27 '22 19:09

sansarp