Hibernate Search is a library that integrates Hibernate ORM with Apache Lucene or Elasticsearch by automatically indexing entities, enabling advanced search functionality: full-text, geospatial, aggregations and more. For more information, see Hibernate Search on hibernate.org.

We just published Hibernate Search 8.0.0.Beta1, the first beta release of the next major version of Hibernate Search.

This version includes the first implementation of the type-safe field references and Hibernate Search’s static metamodel, compatibility with the latest versions of Elasticsearch 9.0 and OpenSearch 3.0, and other small adjustments and dependency upgrades.

What’s new

Hibernate Search 8.0 is still in its early stages of development: some features still need to be completed or may change in a backwards-incompatible way.

Dependency upgrades

Hibernate ORM (HSEARCH-5367)

Hibernate Search targets the Hibernate ORM 7.0 series, which implements Jakarta Persistence 3.2.0. In particular, it is currently based on Hibernate ORM 7.0.0.CR1.

Lucene (HSEARCH-5373)

The Lucene-next backend now uses Lucene 10.2.1.

Elasticsearch (HSEARCH-5361)/(HSEARCH-5365)

The Elasticsearch backend works with Elasticsearch 9.0 and 8.18, as well as other already compatible versions.

OpenSearch (HSEARCH-5363

The Elasticsearch backend works with OpenSearch 3.0, as well as other already compatible versions.

Others

Static metamodel

Hibernate Search’s static metamodel is a set of generated classes that represents the structure of each entity’s index, thereby allowing type-safe references to index fields when creating search queries through the Search DSL.

The basic principles are very similar to the JPA static metamodel available in Hibernate ORM, but in the case of Search the metamodel is about indexes rather than entities.

To try out this new feature, add the annotation processor to the build configuration:

<plugin>
    <artifactId>maven-compiler-plugin</artifactId>
    <executions>
        <execution>
            <id>default-compile</id>
            <configuration>
                <annotationProcessors>
                    <annotationProcessor>org.hibernate.search.processor.HibernateSearchProcessor</annotationProcessor> (1)
                </annotationProcessors>
                <annotationProcessorPaths>
                    <path>
                        <groupId>org.hibernate.search</groupId>
                        <artifactId>hibernate-search-processor</artifactId> (2)
                    </path>
                    <path>
                        <groupId>org.hibernate.search</groupId>
                        <artifactId>hibernate-search-backend-lucene</artifactId> (3)
                    </path>
                </annotationProcessorPaths>
            </configuration>
        </execution>
    </executions>
</plugin>
1 Provide the fully qualified class name of the annotation processor that generates the metamodel.
2 Add the org.hibernate.search:hibernate-search-processor dependency to the annotation processor path (a superset of the compile path), so the Java compiler can find the processor.
3 Add the backend dependency, in this example, the Lucene backend, to the annotation processor path.
The version of both annotation processor and backend dependencies can be omitted in the definition of the annotation paths, because they are defined in the Hibernate Search BOM, which we recommend you import via dependency management. This way the generated metamodel classes will be based on the same backend that the application uses.

And then use the generated metamodel classes to create search queries, e.g.:

SearchSession searchSession = /* ... */; (1)
var scope = Book__.INDEX.scope( searchSession ); (2)

List<Book> hits = searchSession.search( scope )
    .where( f -> f.match()
        .field( Book__.INDEX.title ).field( Book__.INDEX.description ) (3)
        .matching( "robot" ) )
    .fetchHits( 20 );
1 Obtain the search session.
2 Create the search scope over the book index. Using such scope in the Search DSL will automatically limit acceptable field references to the ones obtained from the Book__.INDEX
3 Use the metamodel to reference the fields when creating the queries.

See the corresponding section on static metamodel to find out more.

Other improvements and bug fixes

  • HSEARCH-5305: Allow vector embeddings up to 16,000 dimensions with the Lucene backends.

  • HSEARCH-5358: Fail faster if an enclosing instance parameter is encountered in a projection constructor on JDK 25+.

And more. Please see the release notes for a complete list of changes since the previous releases.

How to get this release

All details are available and up to date on the dedicated page on hibernate.org.

Getting started, migrating

For new applications, refer to the getting started guide:

For existing applications, Hibernate Search 8.0 is a drop-in replacement for 7.2, assuming you also upgrade the dependencies. Information about deprecated configuration and API is included in the migration guide.

Feedback, issues, ideas?

To get in touch, use the following channels:


Back to top