c = DelSolr::Client.new(:server => 'solr', :port => 8983) # updating one document... doc = DelSolr::Document.new doc.add_field('id', 'ABC-123') doc.add_field('name', '8 Gig Shuffle') doc.add_field('description', 'A crazy-tiny MP3 player') c.update!(doc) # posts new document to solr # updating a whole bunch and batching the post to solr models = SomeModel.find(:all) models.each do |model| doc = DelSolr::Document.new doc.add_field('id', model.id) doc.add_field('name', model.name) doc.add_field('description', model.description) c.update(doc) end c.post_update! # post all the updates in one batch c.commit! # post a commit to solrI used a rails example, but delsolr is really intended for ruby and not necessarily rails. Acts_as_solr and the like might suit some better (but not us). This project came out of a piece of code we use internally to manage solr connections. My goal is to get delsolr to the point where we can replace our old implementation. It's not there yet, but it's getting closer. (It's slow going as this is largely done in our "free time".)
Wednesday, October 22, 2008
DelSolr 0.0.2 Released - Added Support for Updates/Delete
A while ago I posted on the first version of delsolr (0.0.1) which provided support for querying solr and not much else :). We just released an update to delsolr (0.0.2). The major change is added support for updating/deleting documents. It's still fairly untested, so, standard disclaimer applies.