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 6.0.0.Beta9.

This release mainly brings a simpler scheme for configuration properties, a new scrolling API, support for projections on multi-valued fields, and complete documentation for all currently implemented features.

It also includes an upgrade to Lucene 8.6.0, Elasticsearch 7.8.0 and Hibernate ORM 5.4.19.Final.

Getting started with Hibernate Search 6

If you want to dive right into the new, shiny Hibernate Search 6, a good starting point is the getting started guide included in the reference documentation.

Hibernate Search 6 APIs differ significantly from Hibernate Search 5.

For more information about migration and what we intend to do to help you, see the migration guide.

What’s new

Simpler configuration scheme

Several improvements to how Hibernate Search handles configuration properties should simplify how your configuration files look like.

In particular:

  • HSEARCH-3950: The default backend now has a dedicated prefix (hibernate.search.backend), meaning single-backend applications no longer need to use the cumbersome named backend scheme (hibernate.search.backends.myBackend.[…​] = […​] + hibernate.search.default_backend = myBackend).

  • HSEARCH-3102: The backend type is no longer necessary if there’s only one backend technology in the classpath.

  • HSEARCH-3967: Defaults for index-level configuration properties can now be given at the backend level and no longer require the index_defaults. prefix.

For example, this:

hibernate.search.default_backend myBackend
hibernate.search.backends.myBackend.type elasticsearch
hibernate.search.backends.myBackend.hosts es.mycompany.com:9200
hibernate.search.backends.myBackend.index_defaults.indexing.queue_count 4

Can now be written more simply, like this:

hibernate.search.backend.hosts es.mycompany.com:9200
hibernate.search.backend.indexing.queue_count 4

Scrolling API

As of HSEARCH-3323, a new scrolling API is available.

Scrolling guarantees that all returned hits are consistent (no duplicates), making it ideal to process large result sets as small chunks:

try ( SearchScroll<Book> scroll = searchSession.search( Book.class )
        .where( f -> f.matchAll() )
        .scroll( 20 ) ) {
    for ( SearchScrollResult<Book> chunk = scroll.next();
            chunk.hasHits(); chunk = scroll.next() ) {
        for ( Book hit : chunk.hits() ) {
            // ... do something with the hits ...

See this section of the documentation for more information.

Projections on multi-valued fields

As of HSEARCH-3391/HSEARCH-3944, projections can now target multi-valued fields.

Just call .multi() on your projection, and it will auto-magically turn into a projection returning a List<T>, where T is the type of your field:

List<List<String>> hits = searchSession.search( Book.class )
        .select( f -> f.field( "authors.lastName", String.class ).multi() )
        .where( f -> f.matchAll() )
        .fetchHits( 20 );

Version upgrades

Hibernate Search 6 requires ORM 5.4.4.Final or later to work correctly. Earlier 5.4.x versions will not work correctly.

Breaking changes

  • HSEARCH-3899: query.explain() now expects to be passed an entity ID instead of a document ID. In short, if your entity has an ID of type Long, you need to pass a Long (previously you had to pass a String).

  • HSEARCH-3939: The internal format used to store GeoPoint fields in the Lucene backend has changed. Applications relying on the Lucene backend and declaring GeoPoint fields should fully reindex their data.

  • HSEARCH-3948: @IndexedEmbedded.storage/ObjectFieldStorage have been renamed to @IndexedEmbedded.structure/ObjectStructure. The older syntax is deprecated and will be removed before the 6.0.0.Final release.


Other improvements and bug fixes

  • HSEARCH-3636: Lucene directories can now be defined on a per-index basis, making it easier to put indexes on completely separate filesystems.

  • HSEARCH-3311: Analyzer discriminators from Hibernate Search 5 are no longer available, but a different solution to the same problem is now documented: the alternative binder.

  • HSEARCH-3929: Hibernate Search is now built with JDK11. Binaries are still compatible with JDK8, and there are no plans to remove that compatibility at the moment.

  • HSEARCH-3307: When targeting multiple indexes in a single search query, detection of field compatibility is now smarter and will no longer yield false negatives.

  • HSEARCH-3941: Distance sorts will no longer throw a ClassCastException when targeting multiple indexes in a single search query.

  • HSEARCH-3266: Using configuration properties from Hibernate Search 5 will now lead to a bootstrap failure, to avoid situations where part of the configuration was incorrectly migrated.

  • HSEARCH-3936: Projectable fields with the Elasticsearch backend are no longer marked as stored = true in the generated mapping.

  • HSEARCH-3938: Hibernate Search 6 will now correctly boot and shut down when using an EnvironmentSynchronizer (typically in JavaEE application servers).

  • HSEARCH-3937: Error messages on boot/shutdown are now correctly displayed when using an EnvironmentSynchronizer (typically in JavaEE application servers).

  • HSEARCH-3506: .boost(float) can now be used on the matchAll, matchId, bool and nested predicates.

  • HSEARCH-3960: Failures of Elasticsearch schema validation now more clearly mention they are about validation of an existing schema in an existing index of an existing Elasticsearch cluster.

And more. For a full list of changes since the previous releases, please see the release notes.

How to get this release

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

Feedback, issues, ideas?

To get in touch, use the following channels:

Back to top