Use Lucene to index a database

April 11th, 2010 by xrigher Leave a reply »

According to Luncene FAQ:

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 LuSql (a specialized tool for moving data from JDBC-accessible databases into Lucene), Hibernate Search, Compass, DBSight, or Solr’s Data Import Handler which all use Lucene internally.

An example: Apache Lucene – Indexing a Database and Searching the Content



  1. Anonymous says:

    thanks for great informations It’s wonderful.
    Al Riyadh

Leave a Reply