How can I use Lucene to index a database?
Connect to the database using JDBC and use an SQL “SELECT” statement to query the database. Then create one Lucene Document object per row and add it to the index. You will probably want to store the ID column so you can later access the matching items. For other (text) columns it might make more sense to only index (not store) them, as the original data is still available in your database. For a more high level approach you might want to have a look at Hibernate Search, Compass, or DBSight, which all use Lucene internally.