Recently I had to implement full text search on a Ruby on Rails application I was developing and based on my needs the easiest way to do it was building a helper array with the keywords needed and search using those keywords.
To illustrate this I’ve implemented stock tickers search using the awesome rstat.us project. Have a look at my Github fork.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | |
and then the controller:
1 2 3 4 5 6 7 8 9 10 11 12 13 | |
So it basically looks for words starting with $ and adds it to the stocks array. We can then search using
1
| |
There are different solutions such as mongoid_search that could be used but for my needs this approach works the best.
MongoDB gives a lot of flexibility for the developer and speeds things up. Of course there are trade-offs to be made while using so YMMV.