Skip to content

Instantly share code, notes, and snippets.

@emmanuelbernard
Last active August 29, 2015 13:57
Show Gist options
  • Save emmanuelbernard/9367947 to your computer and use it in GitHub Desktop.
Save emmanuelbernard/9367947 to your computer and use it in GitHub Desktop.

The release 5.0.0.Alpha2 is now [available on our shiny new website=>http://hibernate.org/search/downloads/]: as the alpha1 release also did, it integrates with Apache Lucene 4.6.1, but now we do it better ;-)

[brush: xml] <dependency> <groupId>org.hibernate</groupId> <artifactId>hibernate-search-orm</artifactId> <version>5.0.0.Alpha2</version> </dependency>

  • More Like This queries New features! A "More Like This" query is a special kind of query which takes a model document as an input, rather than a traditional string. It has been available for you to use since a long time via Lucene's MoreLikeThis Query implementation, but this implementation was rather tricky to use on our richer entity based model. Hibernate Search now provides direct support for this functionality via our Query builder DSL, and in its simplest form looks like this:

`[brush: java] Coffee modelEntity = ...

QueryBuilder qb = fullTextSession.getSearchFactory() .buildQueryBuilder() .forEntity( Coffee.class ) .get();

Query mltQuery = qb .moreLikeThis() .comparingAllFields() .toEntity( modelEntity ) .createQuery();

List<Object[]> results = (List<Object[]>) fullTextSession .createFullTextQuery( mltQuery, Coffee.class ) .list(); `

What does it do? It returns a list of Coffee instances which are similar to the Cofee instance modelEntity. By default the list is of course ordered according to the scoring model, so the top match would be the model itself (this might be surprising but is often useful in practice).

A more extensive blogpost about this will follow, but if you can't wait to learn more the documentation provides many more examples and more details on the implementation: see the [Building queries=>http://docs.jboss.org/hibernate/search/5.0/reference/en-US/html/search-query.html#section-building-lucene-queries] chapter.

The [Apache Lucene Migration Guide=>http://lucene.apache.org/core/4_6_1/MIGRATE.html] might also be useful, but we applied most of it already to the internal engine for you to use transparently.

  • The hibernate-search-analyzers module is removed This module was created years ago when we had to fork some Lucene code to allow an easy migration path, but is now since long an empty module just depending on various commonly used analyzers. It's time for spring cleaning of dependencies, so the no longer needed module is removed: if you where using it, just remove it from your project and include a direct dependency to the analyzers you need from the Apache Lucene ecosystem.

  • What's next? You can find an high level overview on our [Roadmap page=>http://hibernate.org/search/roadmap/], or check the fine grained break down on [this JIRA filter=>https://hibernate.atlassian.net/issues/?filter=12266]. Essentially we're aiming now at OSGi compability and at many usability improvements which had to be postponed to a major release.

++ Useful links = [Downloads=>http://hibernate.org/search/downloads/] = [Documentation=>http://docs.jboss.org/hibernate/search/5.0/reference/en-US/html_single/] = [Migration guide=>https://community.jboss.org/wiki/HibernateSearchMigrationGuide#jive_content_id_Hibernate_Search_500Alpha2] = [JIRA=>https://hibernate.atlassian.net/browse/HSEARCH] = [Forums=>https://forum.hibernate.org/viewforum.php?f=9]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment