Hibernate Lucene Integration

From Foochal

Jump to: navigation, search
  1. Add the @Indexed(index="indexes/essays") annotation on persistent class
  2. Add the @Keyword(id=true) on the primary key field
  3. Add the following snipped to hibernate.cfg.xml
    <session-factory>
    <!-- lucene integration -->
    <!-- lucene file indexing -->
    <property name="hibernate.lucene.default.directory_provider">org.hibernate.lucene.store.FSDirectoryProvider</property>
    <property name="hibernate.lucene.indexBase">c:\\lucene-indexes\\</property>
    <event type="post-commit-update">
    <listener class="org.hibernate.lucene.event.LuceneEventListener" />
    </event>
    <event type="post-commit-insert">
    <listener class="org.hibernate.lucene.event.LuceneEventListener" />
    </event>
    <event type="post-commit-delete">
    <listener class="org.hibernate.lucene.event.LuceneEventListener" />
    </event>
    </session-factory>

Reference: http://www.hibernate.org/hib_docs/annotations/reference/en/html/lucene.html


Personal tools