About a year ago I published an article called Running Hibernate Search with Elasticsearch on Pivotal CF. In several projects I use Hibernate Search. If you’re already have Hibernate-JPA-Entities in your project and you need a full text index for some of them, its really easy to add a Lucene based index by just using some simple annotations in addition to your standard JPA annotations. I also have a post on that topic, check Hibernate Search and Spring Boot: Simple yet powerful archiving.

You can now run Hibernate Search against a local disk based Lucene index as well as against the full blown Elasticsearch index. Together with Spring Data JPA repositories it’s a really valuable tool.

Back in September, Sanne announced the general availably of Hibernate Search 5.8, read it here. It now supports an even broader range of Elasticsearch and also introduces the nice feature of using a Simple Query String.

While upgrading the EuregJUG archive, I ran into two little problems. One got fixed nearly immediately after I reported it (see HSEARCH-2883) and the other one was more on my site.

The EuregJUG site runs on Pivotal Cloud Foundry using an Elasticsearch instance from the marketplace. The PaaS gives me the connection URL including user name and password in the form of user:password@host which is perfectly valid. Sadly that isn’t supported by Hibernate Search anymore.

In the process of splitting the environment variable I have I came across Springs EnvironmentPostProcessor interface. This interface can be used to change the environment after all possible property sources have been evaluated. To make this work, you have to declare it in META-INF/spring.factories . You’ll find the relevant parts here (the declaration to make Spring load this instance early) and the actual implementation (not fancy, just splitting a string). I really like the notion of the Environment post processor. I have every property ready to use and can force some of them to be in a format expected for a third party tool. Could be useful in a starter as well.

With that little change I have a nice search system in place, look for example for everything Spring and Mark. This is how simple the snippet from the extended Spring Data repository looks:

Thanks for the very nice work, Sanne, Yoann and Ales!