Once entities are annotated, they could be queried with regular Apache Lucene query. Simple flow looks like this:
That's how Hibernate Search makes it simple. The only difference from Hibernate's model is FullTextSession usage. Here are few simple details about how Hibernate Search works on top of Apache Lucene:
- for each entity class Apache Lucene creates own index
- Hibernate Search adds a few additional properties (like persistent entity Id and Type) to associate Apache Lucene document and Hibernate entity
- for each query Hibernate Search uses query rewrite to ensure only indexed properties of a particular entity are present in query
- entity's (re)indexing occurs when database transaction commits (but Hibernate Search allows you manually (re)index entity)
Hibernate Search also allows you to use very powerful features like filters (with parameters) and sorting. Filters are extremely useful in case of security rules or search with search results implementation.
It's very simple to integrate and use Hibernate Search into existing applications. It most cases I found integration seamless.
There are a bunch of interesting issues that might occur:
- how to get all indexed properties for entity?
- how to reindex whole existing database?
- how to deploy master/slave(s) configuration?