I have been adding new features on Hibernate Search recently (SVN)
Projection
The ability to project some fields the index only avoiding the database roundtrip.
fullTextQuery.setProjection("id", "summary", "author.name").list();
will return a List<Object[]> like the regular HQL projection
the fieldbridge has to be two way (all built-in are) and the projected fields have to be Store.YES or Store.COMPRESS
It's useful when you want to display a small subset of the data, don't want managed objects, are OK to have a bigger index and if the performance of the non projection strategy doesn't meet your requirements (arguably uncommon);
A few questions:
Currently fields Store.NO or where the fieldbridge is one way are ignored and return null.
The idea behind that is to be able to project across multiple entities / index. Not sure if it's a useful feature.
What do you think of the API? I thought about reusing the Criteria Projection API but it's too tight to SQL
If people could give it a try...
Object load by query rather than batch-size
When querying a given entity type ( eg ftSession.createFullTextQuery(luceneQuery, Book.class) ). HSearch now use a query with an in clause, reducing the number of database roundtrip especially if you don't set up @BatchSize on the entity
Custom query to load objects
You can define the Criteria query that will be use to load the matching objects of a lucene query.
This is especially useful when an object graph (rather than an object) is expected: you can refine the fetchMode.
result = s.createFullTextQuery( query ).setCriteriaQuery(
s.createCriteria( Book.class ).setFetchMode( "authors", FetchMode.JOIN )
).list();
will load the matching books and the associated authors.
Sorting (thanks to Hardy)
fullTextQuery.setSort(luceneSort).list();
Remember that a sorted field must not be tokenized
I will add the ability to index a property multiple times to cope with that.
Expose resultSize()
ie the total number of result regardless of the pagination
fullTextQuery.setMaxResult(20)resultSize() == 3000
A better name is more than welcome.
@IndexedEmbedded for collections
What was available for regular objects is now possible for collections
I am fairly happy with the feature set for beta2, I will probably close a couple of issues and release beta2 (round end of next week, no guaranty though).
Feedback on those features are welcome esp projection, custom query and their APIs
Emmanuel