Compatibility
Java | 11, 17, 21 or 22 |
Hibernate ORM | 6.5 |
Elasticsearch server | 7.10 - 8.14 |
OpenSearch server | 1.3 - 2.14 |
Apache Lucene | 9.11 |
Not compatible with your requirements? Have a look at the other series.
See also the Compatibility policy and Maintenance policy.
Documentation
Documentation for Hibernate Search 7.2 can be accessed through the links below:
You can find more documentation for all series on the documentation page.
How to get it
More information about specific releases (announcements, download links) can be found here.
Getting started
If you want to start using Hibernate Search 7.2, please refer to the getting started guide:
Migrating
If you need to upgrade from a previous series, please refer to the migration guide:
What's new
Hibernate Search 7.2 is still in development:
We encourage you to give it a try and to let us know of any bugs or problems you encounter. |
Latest release announcement (2024-06-10): 7.2.0.Alpha2.
A detailed list of new features, improvements and fixes in this series can be found on our issue tracker.
Dependency upgrades
- Hibernate ORM
-
Hibernate Search now depends on Hibernate ORM 6.5.2.Final.
- Lucene
-
The Lucene backend now uses Lucene 9.11.0.
- Elasticsearch
-
The Elasticsearch backend works with Elasticsearch 8.14, as well as other versions that were already compatible.
- OpenSearch
-
The Elasticsearch backend works with OpenSearch 2.14, as well as other versions that were already compatible.
queryString
/simpleQueryString
predicates for numeric/date fields
simpleQueryString
and
queryString
can now be applied to numeric and date fields.
List<Book> hits = searchSession.search( Book.class )
.where( f -> f.queryString()
.field( "numberOfPages" )
.matching( "[350 TO 800]" )
)
.fetchHits( 20 );
See corresponding sections in simpleQueryString
queryString
documentation
for details.
match
predicate and minimum number of terms that should match
With the introduction of the minimumShouldMatch
option,
similar to the ones already available for the
bool
,
queryString
,
simpleQueryString
predicates,
it is now possible to require that
an arbitrary number of terms from the match string are present in the document
in order for the match
predicate to match.
List<Book> hits = searchSession.search( Book.class )
.where( f -> f.match()
.field( "title" )
.matching( "investigation detective automatic" )
.minimumShouldMatchNumber( 2 ) ) (1)
.fetchHits( 20 ); (2)
1 | At least two terms must match for this predicate to match. |
2 | All returned hits will match at least two of the terms:
their titles will match either investigation and detective ,
investigation and automatic , detective and automatic , or all three of these terms. |
Basic support for parameters at the query level
A number of withParameters(..)
methods were introduced to the Search DSL.
Through them, it is now possible to construct
aggregations,
predicates,
projections,
and sorts
using query parameters.
These can be helpful when there is a need to use the same parameter in multiple parts of the query
or when the same query has to be executed for various parameter values.
SearchScope<Book> scope = searchSession.scope( Book.class );
SearchPredicateFactory factory = scope.predicate();
SearchPredicate predefinedPredicate = factory.withParameters(
params -> factory.bool() (1)
.should( factory.match().field( "title" )
.matching( params.get( "title-param", String.class ) ) ) (2)
.filter( factory.match().field( "genre" )
.matching( params.get( "genre-param", Genre.class ) ) ) (3)
).toPredicate();
List<Book> crimeBooks = searchSession.search( Book.class )
.where( predefinedPredicate ) (4)
.param( "title-param", "robot" ) (5)
.param( "genre-param", Genre.CRIME_FICTION )
.fetchHits( 20 );
List<Book> scienceFictionBooks = searchSession.search( Book.class )
.where( predefinedPredicate ) (6)
.param( "title-param", "spaceship" ) (7)
.param( "genre-param", Genre.SCIENCE_FICTION )
.fetchHits( 20 );
1 | Start creating the .withParameters() predicate. |
2 | Access the query parameter title-param of String type when constructing the predicate. |
3 | Access the query parameter genre-param of Genre enum type when constructing the predicate. |
4 | Use the predefined, parameterized predicate in a query. |
5 | Set parameters required by the predicate at the query level. |
6 | Reuse the predefined, parameterized predicate in a query. |
7 | Set a different pair of parameters required by the predicate at the query level. |
@DistanceProjection
to map a constructor parameter to a distance projection
With the introduction of the query parameters, it is now possible to define a
@DistanceProjection
that can be used in the projection constructors.
@ProjectionConstructor
public record MyAuthorPlaceProjection(
@DistanceProjection( (1)
fromParam = "point-param", (2)
path = "placeOfBirth") (3)
Double distance ) {
}
1 | Annotate the parameter that should receive the distance value with @DistanceProjection . |
2 | Specify the query parameter that will be used to calculate the distance from. |
3 | Optionally, customize the path, since most likely the GeoPoint property of the entity will have a different name from the
distance property in a projection. |
List<MyAuthorPlaceProjection> hits = searchSession.search( Author.class )
.select( MyAuthorPlaceProjection.class )
.where( f -> f.matchAll() )
.param( "point-param", GeoPoint.of( latitude, longitude ) ) (1)
.fetchHits( 20 );
1 | Pass a query parameter value, with the same name point-param as in the @DistanceProjection fromParam of a projection constructor. |
Document tree projection
With the Lucene backend, requesting a document tree projection is now possible.
This new .documentTree()
projection returns the matched document as a tree containing native Lucene Document
and corresponding nested tree nodes.
List<DocumentTree> hits = searchSession.search( Book.class )
.extension( LuceneExtension.get() )
.select( f -> f.documentTree() )
.where( f -> f.matchAll() )
.fetchHits( 20 );
DocumentTree documentTree = hits.get( 0 );
Document rootDocument = documentTree.document();
Map<String, Collection<DocumentTree>> nestedDocuments = documentTree.nested();
// ...
within
/withinAny
for the range predicate
The range
predicate can now accept multiple ranges,
matching the document when the value is within at least one of the provided ranges.
List<Book> hits = searchSession.search( Book.class )
.where( f -> f.range().field( "pageCount" )
.withinAny(
Range.between( 200, 250 ),
Range.between( 500, 800 )
) )
.fetchHits( 20 );
Switch project license to Apache License 2.0
We are also pleased to announce that Hibernate Search 7.2.0.Alpha2 is licensed under Apache License 2.0. This change is a part of a broader initiative to re-license Hibernate projects with the Apache License 2.0.
Development versions (SNAPSHOTS)
The latest development versions of Maven artifacts for Hibernate Search are published to the OSSRH snapshots repository.
You should only need those (unstable) versions for testing recently merged patches, and should never use them in production.
To consume these artifacts, you may need to configure your build tool to fetch artifacts
from
and to enable snapshots:
Releases in this series
Switch project license to Apache License 2.0, accept multiple ranges in a range predicate, compatibility with Elasticsearch 8.14, upgrade to Lucene 9.11, other bugfixes, improvements and upgrades
Maven artifacts Download Resolved issues Release announcement
Enable query string predicates on numeric/date fields, query parameters, document tree projection for the Lucene backend, new APIs to work with analyzers, compatibility with OpenSearch 2.14, upgrade to Lucene 9.10, upgrade to Hibernate ORM 6.5, other bugfixes, improvements and upgrades
Maven artifacts Download Resolved issues Release announcement