The title is a bit skeptical. Isn’t it? But trust me, it’s true. You can implement solr power searching in your Ruby on Rails application without knowing Solr. Yes, you off course know about Solr. What you don’t know is how to make it work for you. Let’s check how can you power your application with Solr using Sunspot gem.
What is Sunspot?
Sunspot is a Ruby library for expressive, powerful interaction with the Solr search engine. Sunspot is built on top of the RSolr library, which provides a low-level interface for Solr interaction; Sunspot provides a simple, intuitive, expressive DSL backed by powerful features for indexing objects and searching for them.
Using the sunspots DSL, you can easily implement solr powered searching. Its drop-in support with Rails models let you power your site with a few lines of codes.
Add the following line in your Bundle file.
Then run ‘bundle install’. Continue reading →
Recently, I’ve worked with Tastypie which is my first introduction to tastypie. Tastypie itself is wonderful and very easy to work. However, my first catch was that I’ve to use it in a scenario where data source is not django’s ORM. My goal is to expose some API endpoints but the data will come from some other external API. Confusing? Let’s discuss about the implementation not about the wisdom of use cases. If you do not have introduction to the Tastypie, please have a look at their documentation.
Generally, when we create a Tastypie resource, our class inherits ModelResource. ModelResource is actually provides django’s ORM specific accesses as the resource is created on top of Django models. The fact is that, ModelResource is a thin wrapper on top of it’s Resource class and overrides few methods. If we want to use our custom data sources, we will have to override some methods of this Resource class based on our requirements. The methods we have to override are:
Continue reading →