We did a big refactoring of the query engine, hence the alpha tag. If you could focus your tests in this area and see if there are any issues, we would be forever grateful.
This release comes with the usual mix of bug fixes, optimizations and new features.
Query engine refactoring
This was a biggie and the objective is that it does not affect you :) We have a medium term goal to make Hibernate Search not depend on Hibernate Core. Extracting the query engine core into well defined SPIs (Service Provider Interfaces) is a milestone for this. The first beneficiary is the Infinispan query module which will become much more resilient to Hibernate Search version changes.
As said earlier, test your applications queries. They should still run without any API change. Let us know otherwise.
Update index only when an indexed property changes
With previous version, when an @Indexed entity changes in Hibernate Core, it is reindexed by Hibernate Search even if none of the indexed properties have effectively changed (after all not all properties are indexed). Hibernate Search 3.4 is smarter in this area and tries not to reindex entities whose indexed properties are unchanged. In some situations like dynamic boosting or class-level bridges, Hibernate Search cannot be certain and always reindex to be safer.
This optimization should speed things up quite significantly for some applications. Check the documentation for more information.
Look for entities in the second level cache
In some environments, most if not all of the searched entities are in the second level cache. This is especially true when you use a distributed second level cache like Infinispan. You can ask Hibernate Search to look in the second level cache before trying to fetch data from the database.
FullTextQuery query = session.createFullTextQuery(luceneQuery, User.class);
query.initializeObjectWith(
ObjectLookupMethod.SECOND_LEVEL_CACHE,
DatabaseRetrievalMethod.QUERY
);
List results = query.getResultList();
Of course your entities must be cacheable :) If your entities are most likely in the persistence context (the Hibernate session), you can use ObjectLookupMethod.PERSISTENCE_CONTEXT instead.
MassIndexer improvements
The mass indexer module has had a few improvementse:
- multithreading of the text analysis phase
- improve monitoring the mass indexer state and progress by letting you plug a custom implementation (see MassIndexerProgressMonitor)
Faceting
Very requested and useful feature, you can now play with the first alpha preview of the new Faceting engine API.
Field Caching
It's now possible to use Lucene's FieldCache to provide an extra boost to query performance: see the reference documentation.
Other performance improvements
We have found a couple of tricks to improve overall performances. We more aggressively cache some metadata to lower the reflection overhead and we push some additional buttons in Lucene for you to reduce query time.
Give us feedback
Please give us feedback, we have an aggressive release schedule ahead as we are planning the GA version for end of this month.
Check out the new release on JBoss.org's Maven repository or download the distribution. You can also read the documentation.
If you find an issue, shoot.
Sounds very nice. But where can I find the documentation for the new faceting API?
Matthias
The faceting API is really still in an Alpha stage. At the moment you can do discrete value faceting and range faceting on numbers. The configuration is atm via a QueryBuilder instance, but there will also be a annotation based configuration available similar to filter definitions. Via the DSL a simple facet search looks like this:
builder = fullTextSession.getSearchFactory().buildQueryBuilder().forEntity( Car.class ).get(); FacetRequest facet = builder.facet() .name( "myFacet" ) .onField( "cubicCentimeters" ) .createFacet(); Query luceneQuery = builder.keyword().onField( "make" ).matching( "Honda" ).createQuery(); FullTextQuery query = fullTextSession.createFullTextQuery( luceneQuery, Car.class ); query.enableFacet( facet ); Map<String, FacetResult> facetResults = query.getFacetResults(); //...The design is still in progress so there will be more changes ahead. The public API classes are currently in org.hibernate.search.query.facet. Have a look at SimpleFacetingTest and RangeFacetingTest for more examples. Hope this helps for now. Better documentation will be included once the API has settled.I am missing, how to set a facet value as a filter for the search in the above test cases. Normally after getting the facet values the user has the option the select one as a filter for the search. I cant see how it is done in the examples. Am I missing something or is there no information about this up to now?
in the moment I am using bobo-browse for faceted search. but I am looking forward to you implementation as it will -- hopefully -- much better integrate with the rest of hibernate search. thanks for your work!
This will be part of the next release. Right now you would have to take the value from a Facet instance, create a TermQuery/RangeQuery from it and combine it with the existing query using a BooleanQuery. Obviously we want to make this easier for the developers. I see two alternatives. For exmaple, we could pass the original query into a Facet instance and get the new boolean query returned. In fact we probably need to pass in the original query, because we can take transparently care of this. Either way you would create a new fulltext query from the returned boolean query. The alternative would be to have an additional method on FullTextQuery, something like applyFacet(Facet facet). Not sure yet which way to go. Feel free to give some feedback.
If it is build as an own query, I would miss an important feature. This would mean -- as I understand it -- that for the applied filter only one facet would be valid, as the facets are build from the result. So if I have a filter with five values (1, 2, 3, 4, 5) and I select value , I would not get any facets for the other values, if I code this value directly into the query -- or am I wrong? But I would like to have the possibility to get the facet numbers for the other values, too. So that I can then also select e.g. value . So that I get all results that have either value 2 or value 3.
I hope, that I was able to make clear, what possibility I would like to have for drilling down the results.