Hank Gay
Hank Gay

Reputation: 71939

Is there a set of best practices for building a Lucene index from a relational DB?

I'm looking into using Lucene and/or Solr to provide search in an RDBMS-powered web application. Unfortunately for me, all the documentation I've skimmed deals with how to get the data out of the index; I'm more concerned with how to build a useful index. Are there any "best practices" for doing this?

Upvotes: 2

Views: 2708

Answers (4)

talanb
talanb

Reputation: 994

We are rolling out our first application that uses Solr tonight. With Solr 1.3, they've included the DataImportHandler that allows you to specify your database tables (they call them entities) along with their relationships. Once defined, a simple HTTP request will tirgger an import of your data.

Take a look at the Solr wiki page for DataImportHandler for details.

Upvotes: 1

Joe Liversedge
Joe Liversedge

Reputation: 4154

I haven't explored this at all, but take a look at LuSql.

Using Solr would be straightforward as well but there'll be some DRY-violations with the Solr schema.xml and your actual database schema. (FYI, Solr does support wildcards, though.)

Upvotes: 2

erickson
erickson

Reputation: 269637

Will multiple applications be writing to the database? If so, it's a bit tricky; you have to have some mechanism to identify new records to feed to the Lucene indexer.

Another point to consider is do you want one index that covers all of your tables, or one index per table. In general, I recommend one index, with a field in that index to indicate which table the record came from.

Hibernate has support for full text search, if you want to search persistent objects rather than unstructured documents.

There's an OpenSymphony project called Compass of which you should be aware. I have stayed away from it myself, primarily because it seems to be way more complicated than search needs to be. Also, as I can tell from the documentation (I confess I haven't found the time necessary to read it all), it stores Lucene segments as blobs in the database. If you're familiar with the Lucene architecture, Compass implements a Lucene Directory on top of the database. I think this is the wrong approach. I would leverage the database's built-in support for indexing and implement a Lucene IndexReader instead. The same criticism applies to distributed cache implementations, etc.

Upvotes: 2

splattne
splattne

Reputation: 104040

As introduction:

Brian McCallister wrote a nice blog post: Using Lucene with OJB.

Upvotes: 1

Related Questions