Santa has come early to deliver Hibernate Search 3.3! This release comes with many new interesting and useful features as well as its lot of performance improvements and bug fixes.
Compatibility
This version has been tailored to work in conjunction with:
- JBoss AS 6
- Seam 2.2.1
- Hibernate Core 3.6
Queries
Most likely the biggest feature is the new query DSL providing an easy-to-use, easy-to-read fluent API for programmatic queries. The Query DSL abstracts things like the right property bridge to use, the right analyzer to use for a given property etc. You work at the object level and let Hibernate Search do the conversion to the Lucene world.
Here is a fairly complex example
QueryBuilder mythQB = searchFactory.buildQueryBuilder().forEntity( Myth.class ).get(); //look for popular modern myths that are not urban Date twentiethCentury = ...; Query luceneQuery = mythQB .bool() .must( mythQB.keyword().onField("description_stem").matching("urban").createQuery() ) .not() .must( mythQB .range() .onField("starred") .from(3).excludeLimit() .to(5) .createQuery() ) .must( mythQB .range() .onField("creationDate") .above(twentiethCentury) .createQuery() ) .createQuery();
We hope this will make complex queries much easier and much less buggy for you. You can get more info here.
While we are on the subject, you can now limit the time a query takes. While this is a hint for Hibernate Search and is a best effort
, you can do it in two ways:
- throw an exception if the query takes too long
- return only the elements found when the time limit is reached (partial results)
More info here.
Backend
We have reworked the queuing algorithm which should make things substantially faster for people with complex object graphs and with massive changes.
You can now store your index in the Infinispan grid system (in a distributed way) instead of the traditional file-system based approach. The index data is store on the grid and shared amongst the cluster of machines. This eliminates some of the complexity of copying files between and master and a slave. More info here.
Hibernate Search now exposes various statistics like the average query time, the slowest query etc. This will help you tune your application with hard data. More info here.
Indexing and Lucene
We have migrated to Lucene 3.0. While this new version has some backward incompatibilities in its API, Hibernate Search shields you against all of this. Your application will be faster with minimal to no change to your application.
Note that to that effect, we have introduced a new artifact org.hibernate:hibernate-search-analyzers. This artifact is a replacement for org.apache.solr:solr-core when using the Solr analyzer framework. So far the namespace of the classes has not changed. Existing @AnalyzerDef definitions should continue to work.
We also have added support for the new Lucene NumericField. Numeric fields can provides significant query improvements on numeric properties. While this feature is marked as experimental in Lucene, we are quite optimistic about it.
@Field @NumericField Long size;
More info here.
And many more
There are some of the most prominent new features, don't hesitate to look for previous blog entries on the subject and of course the changelog and the reference documentation which has been updated and cleaned up.
Check out the new release on JBoss.org's Maven repository or download the distribution. You can also read the documentation.
Many thanks to the various contributors, in particular Gustavo from Sourcesense . And welcome Sanne to the team (sorry for the rough release baptism :) ).
Happy searching!