Hibernate Search 6.0.0.Alpha4 released!

Posted by    |      

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.Alpha4, the fourth release for the still-in-development 6.0 branch. This release mainly adds an "exists" predicate, improves the DSL by allowing to bypass DSL and projection converters or to override analyzers, restores the Elasticsearch AWS integration, and upgrades the Lucene backend to Lucene 8.

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 is still in development and its APIs differ significantly from Search 5.

For more information about the current status of this branch, see the page dedicated to Search 6 on hibernate.org.

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

What’s new

New "exists" predicate

We added support for the "exists" predicate in the Search DSL, allowing to filter documents according to the presence or absence of a non-null value for a given field:

SearchQuery<MyEntity> query = searchSession.search(MyEntity.class).asEntity()
    .predicate(f -> f.exists().onField("someField"))
    .toQuery();

The Elasticsearch AWS integration is back

We restored the AWS integration as part of HSEARCH-3051. See the dedicated section in the documentation to configure your backend to talk with an AWS-managed Elasticsearch service.

Converters can be bypassed in predicates

DSL and projection converters automatically convert values from the type expected by the user to the underlying type exposed by backends. For example java.util.Date properties have a converter between that type and Instant.

Just like the .ignoreFieldBridge option in Search 5, there is now an option to bypass these converters in Search 6:

// When the value to match is a java.util.Date
Date dateToMatch = /* ... */;
SearchQuery<MyEntity> query = searchSession.search(MyEntity.class).asEntity()
    .predicate(f -> f.match().onField("myJavaUtilDate").matching(dateToMatch))
    .toQuery();

// When the value to match is a java.time.Instant
Instant instantToMatch = /* ... */;
SearchQuery<MyEntity> query = searchSession.search(MyEntity.class).asEntity()
    .predicate(f -> f.match().onField("myJavaUtilDate").matching(instantToMatch, DslConverter.DISABLED))
    .toQuery();
// When we need the projection as a java.util.Date
SearchQuery<Date> query = searchSession.search(MyEntity.class)
    .asProjection(f -> f.field("myJavaUtilDate", Date.class)
    .predicate(f -> f.matchAll())
    .toQuery();

// When we need the projection as a java.time.Instant
SearchQuery<Instant> query = searchSession.search(MyEntity.class)
    .asProjection(f -> f.field("myJavaUtilDate", Instant.class, ProjectionConverter.DISABLED)
    .predicate(f -> f.matchAll())
    .toQuery();

Analyzers can be overridden at query time

Analyzers could already be overridden in Search 5, but only at the QueryBuilder level and on a per-field basis, which could be annoying if you had many fields in your predicates or if you needed two predicates with different overrides.

SearchQuery<MyEntity> query = searchSession.search(MyEntity.class).asEntity()
    .predicate(f -> f.match().onField("name_autocomplete").matching(userInput).analyzer("edgengram_query"))
    .toQuery();

Configuration

Since HSEARCH-3521, the property keys for index-scoped configuration properties are now prefixed with .backends.<backend name>. For example:

hibernate.search.backends.myBackend.indexes.myIndex.lifecycle.strategy = create

Version upgrades

Other improvements and bug fixes

  • HSEARCH-3507: Improve consistency of naming for methods related to native Elasticsearch/Lucene features (fromJsonString, etc.)

  • HSEARCH-3554: The Elasticsearch backend defaults to a 10 element hit limit

  • HSEARCH-2534: Allow using query-only analyzer definitions with Elasticsearch

  • HSEARCH-2185: Phrase query with the DSL does not consider the ignoreAnalyzer() options

  • HSEARCH-2423: Projecting an unstored field should raise an exception with Elasticsearch

  • HSEARCH-2518: Allow to assign a name to an analyzer class/instance

  • HSEARCH-2757: Allow usage of FieldSelectors when using Spatial indexing

  • HSEARCH-3530: Update the date formats in the reference documentation

  • HSEARCH-3532: Fix the java module name for hibernate-search-util-common

  • HSEARCH-3538: Disabling projection converters in projections is ignored when checking compatibility

  • HSEARCH-3540: The NONE Elasticsearch index lifecycle strategy throws an AssertionFailure

  • HSEARCH-3543: Allow to set GeoPointBridges as sortable to enable distance sorts

  • HSEARCH-3548: ZonedDateTime with zone = ZoneOffset.UTC fails when indexing in Elasticsearch 5.6

  • HSEARCH-3549: Indexing MonthDay.of( 2, 29 ) fails on Elasticsearch

  • HSEARCH-3557: ZonedDateTime at later offset during DST change gets parsed incorrectly

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