We just published Hibernate Search 6.0.0.Beta3. This release mainly brings schema improvements, deep customization of Elasticsearch search requests, more powerful bridge definitions, and restores features such as the search query timeouts. It also includes upgrades to Lucene 8.3.0, Elasticsearch 7.5 and Hibernate ORM 5.4.10.Final.
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 Search 5.
For more information about migration and what we intend to do to help you, see the migration guide.
We made several improvements to the metadata fields stored in each document (identifier, type, …), in order to only store what is strictly necessary and to rely on doc-values rather than stored fields (HSEARCH-3657).
Also, in the Elasticsearch backend, we added a new
to better handle multi-index search queries targeting index aliases (HSEARCH-3765)
and changed the name of fields used for discriminator-based multi-tenancy
_tenant_doc_id, see HSEARCH-3788).
These improvements come at a cost: when upgrading from Beta2 to Beta3, existing data will need to be reindexed.
new APIs were introduced to allow the manipulation of the JSON of Elasticsearch search requests
and the retrieval of the response as raw JSON.
This will allow leveraging Elasticsearch features that are not (yet) available in the Search DSL,
such as suggesters,
while still taking advantage of the DSL where possible (
match predicate, sorts, projections, …).
See this section of the documentation
for more information.
Bridges gained several improvements:
HSEARCH-3135: The concept of custom mapping annotations was streamlined: it is no longer limited to the type bridge and property bridge, and can now also be used for value bridges too. In fact, custom annotations can now apply pretty much every mapping feature: bridges, indexed-embedded, marking a type as indexed, …
ValueBinderis no longer limited to standard field types: it can now bind a value to more exotic field types, such as a "native" Elasticsearch field whose content is defined as JSON directly.
HSEARCH-3766: Custom annotations are now optional for type and property bridges. To apply a bridge that does not define a dedicated annotation, just apply the built-in
@PropertyBinding(…)annotations to the type/property, setting its attribute to a reference to your binder. Bridges applied this way cannot be parameterized.
For up-to-date information about bridges and how to use them, see the dedicated section in the reference documentation.
exists predicate introduced in Search 6 can now target object fields
An object field will be considered as existing in a given document
when it has at least one existing (non-null) sub-field in that document.
In the example below, all clients that have an order with at least one non-null indexed field will be present in the result:
List<Client> clientsWithAtLeastOneOrder = searchSession.search(Client.class) .predicate(f -> f.exists().field("orders")) .fetch( 20 );
As of HSEARCH-3352, it is once again possible to set timeouts on search queries, similarly to what was possible in Search 5.
Two kinds of timeouts are available:
failAfter(long, TimeUnit): a "hard" timeout that will abort the search query and throw an exception;
truncateAfter(long, TimeUnit): a "soft" timeout that will stop the result collection and return a truncated result.
These timeouts are available for both the Lucene backend and the Elasticsearch backend.
Additionally, as of HSEARCH-3456,
SearchResult interface now exposes information about the query execution time (
and a flag indicating whether the query timed out (
See the dedicated section in the reference documentation for more information.
Hibernate Search 6 requires ORM 5.4.4.Final or later to work correctly. Earlier 5.4.x versions will not work correctly.
HSEARCH-3756: Multi-valued configuration properties now must be specified using commas as a separator, instead of blanks. This affects in particular the configuration of Elasticsearch hosts.
HSEARCH-3757: The protocol used to contact Elasticsearch (
https) must now be specified separately in the dedicated
hibernate.search.backends.<backend name>.protocolproperty. It can no longer be specified as part of the
*Binderinterfaces no longer have a generic type parameter nor an
initialize()method. Processing of custom annotations, for bridges or otherwise, are now implemented by meta-annotating the custom annotation with
@PropertyMappingand implementing the dedicated interface
PropertyMappingAnnotationProcessor. Binders that do not need to accept parameters can be applied directly to a type/property using the built-in
HSEARCH-3748: Some methods related to bridges in the programmatic API that couldn’t possibly work were removed.
HSEARCH-3750: Use auto-expanding entries in the documentation TOC
HSEARCH-3753: APIs related to the definition of custom
ContainerExtractorimplementations are now correctly marked as experimental.
HSEARCH-1401: Allow integrators to declare entities whose structure is defined programmatically ("free-form").
HSEARCH-3634: Clarify the error message when a
@javax.persistence.Transientproperty is missing a
HSEARCH-3764: It is now possible to disable value conversion in the
id()predicate, so as to pass the document ID (a string) directly.
query.explain()with the Elasticsearch backend no longer fails when using projections or multi-tenancy.
HSEARCH-3693: Some missing log messages from Search 5, in particular the Hibernate Search version displayed on startup, were restored.
And more. For a full list of changes since the previous releases, please see the release notes.
All details are available and up to date on the dedicated page on hibernate.org.