In Search of the Grand Unified Data Model

Since I started working on AltLaw.org a little over a year ago, I’ve struggled with the data model. I’ve got around half a million documents, totally unstructured, from a dozen different sources. Each source has its own quirks and problems that have to be corrected before it’s useful.

When I started, I was using MySQL + the filesystem + Ferret. Keeping all that in sync, even with Rails’ ActiveRecord, was tricky, and searches were slow. Now I’ve got everything stored directly in a Solr index, which is very fast for searching. But it’s not so great when I want to change, say, how I convert the source PDFs into HTML, and I have to re-index half a million documents. And it can’t store structured data very well, so I augment it with serialized hash tables and SQLite.

What I want is a storage engine that combines properties of a relational database and a full-text search engine. It would put structured fields into SQL-like tables and unstructured fields into an inverted index for text searches. I want to be able to do queries that combine structured and unstructured data, like “cases decided in the Second Circuit between 1990 and 2000 that cite Sony v. Universal and contain the phrase ‘fair use’.” I also want to store metadata about my metadata, like where it came from, how accurate I think it is, etc.

I’ve been exploring some interesting alternatives: CouchDB is probably the closest to what I want, but it’s still under heavy development. DSpace is oriented more towards archival than search. Then there’s the big RDF monster, maybe the most flexible data model ever, which makes it correspondingly difficult to grasp.

I’m come to the conclusion that there is no perfect data model. Or, to put it another way, no storage engine is going to do my work for me. What I need to do is come up with a solid, flexible API that provides just the features I need, then put that API in front of one or more back-ends (Lucene, SQL, the filesystem) that handle whatever they’re best at.

3 Replies to “In Search of the Grand Unified Data Model”

  1. I would encourage you to take a closer look at CouchDB. Despite the ongoing development, a lot of things work quite well. If you need assistance in any form, check out the Google Group or the Freenet #couchdb channel on IRC.

    Cheers,
    Jan

  2. Jan Says: I would encourage you to take a closer look at CouchDB.

    Thanks Jan. I have looked again — I really like the document-oriented model and the ability to store binary attachments. I’m waiting for 1) completed Lucene integration, and 2) breaking the 2 GB limit. Then CouchDB will really be perfect for my needs. But until then, Solr is a finished product that provides similar advantages.

  3. Take a look at PostgreSQL. It has built-in full-text search (integrated as of v8.3) with word stemming, weighted indexes, and all that. But since it’s a first-class part of the DBMS, it supports transactions, partial indexes, and other fun stuff.

Comments are closed.