Search

27.2. Configuration

download PDF
Hibernate Search is configured either in the META-INF/persistence.xml or hibernate.cfg.xml file.
Hibernate Search configuration has sensible defaults for most configuration parameters. The following is an example of a minimal persistence unit configuration:
<persistence-unit name="sample">
  <jta-data-source>java:/DefaultDS</jta-data-source>
  <properties>
    [...]
    <!-- use a file system based index -->
    <property name="hibernate.search.default.directory_provider" 
              value="org.hibernate.search.store.FSDirectoryProvider"/>
    <!-- directory where the indexes will be stored -->
    <property name="hibernate.search.default.indexBase" 
              value="/Users/prod/apps/dvdstore/dvdindexes"/>
  </properties>
</persistence-unit>

Note

When using Hibernate Search 3.1.x, more event listeners are required, but these are registered automatically by Hibernate Annotations. Refer to the Hibernate Search Reference Guide to learn to configure event listeners without using Hibernate EntityManager and Hibernate Annotations.
The following JARs must be deployed alongside the configuration file:
  • hibernate-search.jar
  • hibernate-commons-annotations.jar
  • lucene-core.jar

Note

If you deploy these in an EAR, remember to update application.xml.
Red Hat logoGithubRedditYoutubeTwitter

Learn

Try, buy, & sell

Communities

About Red Hat Documentation

We help Red Hat users innovate and achieve their goals with our products and services with content they can trust.

Making open source more inclusive

Red Hat is committed to replacing problematic language in our code, documentation, and web properties. For more details, see the Red Hat Blog.

About Red Hat

We deliver hardened solutions that make it easier for enterprises to work across platforms and environments, from the core datacenter to the network edge.

© 2024 Red Hat, Inc.