views:

765

answers:

2

I want to use lucene.net to index records in our database. The records are stored in several different tables and tied together through a records table. Would it be better to index each table separately and tie the search results together in code, or should I tie the records together coming out of the database and place them all in one index?

Any other suggestions would be helpful as well.

A: 

Lucene isn't tied to database tables, you select the information you want in a Lucene document. I would likely be better to let Lucene handle the merging and ranking of results rather than doing it yourself.

vfilby
I realize it's not tied to tables. I was wondering if I should leave the tables as they are and search them, or pull them out the way I would want them and search that way.
Aaron Smith
Regardless of the data structure in your tables you should create the Lucene document in a way that makes sense to you. ALl the data you want to search should be in it. They use one index. The pain of merging multiple results isn't worth it.
vfilby
+2  A: 

If you make a Lucene index that corresponds to each table, then 1) you're going to have to do the work of performing the search against each index and 2) merging the search results in some magical fashion. Lucene is already set up to search documents with multiple fields (see MultiFieldQueryParser), and give you a unified result set.

Even if you decide after making the index that you occasionally only want to search based on the data that came from a single table, you can just use the normal QueryParser to search only the corresponding field of your documents.

Jay Kominek