Adventures into CouchDB and Rails

May 4, 2009

Quick Tip: CouchDB with Lucene Search

Filed under: CouchDB — Tags: , , , — zdzolton @ 4:13 pm

So, I’m still loving Bob Newson’s CouchDB-Lucene external integration.

Here’s a quick way to monkey-patch on a search method:

CouchRest::Database.class_eval do 
  def search query, options={} 
    CouchRest.get "#{@uri}/_fti?#{options.merge(:q => query).to_query}" 


When Upgrading CouchDB at Some Point…

Filed under: CouchDB — Tags: , , — zdzolton @ 3:15 pm

Versioning with Mac Ports can kinda suck, and new CouchDB versions are often incompatible with the old version’s data files.

Idea: Use CouchDBX, during incompatible upgrades, as a holding pen for your local data!

  1. Download CouchDBX
  2. Replicate from your Mac Ports-installed databases to
  3. Delete “old” databases from your Mac Ports-installed CouchDB
  4. Upgrade your Mac Ports-installed CouchDB to some new, binary-incompatible version
  5. Re-create the databases in the newly-upgraded CouchDB installation
  6. Replicate from your CouchDBX databases to the Mac Ports-installed CouchDB
  7. Enjoy! Or, Profit! (You choose…)

See?! That was so bad, was it?

May 1, 2009

Computational Evangelism

Filed under: CouchDB — zdzolton @ 4:17 pm

Using CouchDB, or any relatively new open source software, requires much work and dedication.
Here I present my list of my favorite reasons to use CouchDB:

It’s Made of the Web

  • All database operations are through REST verbs—a browser or CURL are all you need to get started!
  • Etags mean documents and views are ready for caching
  • JSON representation of all data means no-brainer mapping to programming language constructs
  • JavaScript for all scripting duties means no context swaps

Map-Reduce Indexing

  • Map-reduce functions are side-effect free, and easy to reason about using imperative OR functional techniques
  • View indexes execute explicitly, whereas SQL gurus use voodoo to change queries, hoping that the query planner decides to use the correct index
  • Functional JavaScript programming techniques can succinctly express map-reduce logic
  • It’s the algorithm that powers Google!

The Meek Shall Inherit the Earth(‘s Data)

  • Schema-less database removes impediments to change
  • Flat key-value storage is easy to reason about
  • UUIDs, instead of sequence IDs, means any two databases can replicate documents
  • Seriously easy replication: Push/Pull == POST/GET
  • AJAX-only CouchApps + Easy replication == open source apps + viral databases

Of course, swapping your SQL brain out, for a Map-Reduce one, takes a bit of time. In my opinion, however, CouchDB’s feature set, maps better to the requirements for many up-and-coming websites.

Create a free website or blog at