Hibernate Search 4.0.0 Alpha2 is out

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.

Continuing on the Hibernate Search 4 rails, we have just released Hibernate Search 4.0.0 Alpha2. It's the usual lot of bug fixes but also contains some interesting new features made possible by the refactoring started in the 4 series.

Near Realtime Search

Traditionally Lucene has focused on tremendous Search performance, but writes to the index could be costly even for small changes (by triggering segment reorganization).

So far in Hibernate Search, every time the changes related to a transaction where applied to the index, a commit was needed on the index to make sure newly started Queries would see the new data.

Taking advantage of Lucene's new Near Realtime advancements, Hibernate Search can now search the uncommitted buffers which are still in memory, avoiding costly commits and let the IndexWriter flush periodically as it needs for optimal memory management. Note that Hibernate Search still makes sure that a Query will only see fully committed transactions (no dirty reads).

To experience this new writing performance yourself, a single configuration line is required. Is that not a good motivation to upgrade now?

There are a few limitations though:

  • You cannot use it in a cluster using Hibernate Search's JMS or JGroups clustering approaches
  • You cannot use it in a cluster using Infinispan but you don't need to anyways as Infinispan is in-memory
  • Index changes are flushed periodically so updates might be lost in case of crashes - you will of course be able to recover the state by reindexing the database if that happens

To summarize near real time: it's much faster for writes, the index is less safe (crash might lose data), it cannot be used in a cluster

Pluggable IndexManager implementations

The Near Realtime IndexManager is the first alternative implementation to the default IndexManager of a series to come. You can now provide your own and plug any indexing backend ; you can override the whole design of how to interact with the Lucene index. Of course if you do, we would love to hear about it and even accept contributions :)

Long requested features

This has been a long requested feature, you can now use @IndexedEmbedded on collections of basic types

@Entity
@Indexed
class User {
    [...]
    @IndexedEmbedded
    @ElementCollection
    public Set<String> getNicknames() { return nicknames; }
}

Another requested feature: you can use full-text queries with a Criteria query that will restrict your results (ie with a where clause) - only criteria queries redefining the fetching strategy were allowed before. However, in this particular case, query.getResultSize() is not supported (exception). You need to use query.list().size() instead.

Mixing full-text query and criteria restrictions is useful when you want to refine the query further based on data not present in the index. However, we do not recommend this approach, you are better off putting the necessary information in the full-text index.

More

There are a few additional interesting features including support for JGroups on IPv6 and a much improved serialization layer based on Avro. It's now faster than in Alpha1 and the sample payload is 6.6 times smaller than what it used to be in Hibernate Search 3.4.

Java 7 warning

Java 7 has a few bugs that have not been fixed at the time this blog hits the press. It is not safe to use it with Lucene and Hibernate Search. More info here.

Get the release

Check out the release and as usual, make sure you read the Migration guide when you upgrade from a previous version.

The community has been stellar. Special thanks to Davide D'Alto and Elmer van Chastelet for going through the laser scrutiny of our design and code review process :)


Back to top