You are right, there are some limitations; in some cases easy to work around, in some cases harder.
I would like to discuss how to implement a general solution for all harder cases; some ideas could be to use pagination as you suggest, or apply some sort of object filter on a fulltext scrollable result (something like a validator, which discards some elements from the resultset), or have a general purpose combiner for HQL restrictions on top of a fulltext search.
As you noticed this solutions are tricky especially for the result count, but also the performance is affected by many factors: a savvy programmer would probably prefer to build it's own specific optimized solution instead than relying on a "blind" general purpose pattern, I mean "blind" as unaware of the specifics of the persistent model; very often there is some way to think of something smart depending on the case.
In your specific case, I would really recommend to just index the missing enums and integers: that's really the best performing solution and it won't take up much space in the index. Most of the systems I've worked on use a sort of "strategy selection": they look at the fields requested by the user, and then take a decision about using plain HQL or go the fulltext way. Of course to cover the most complex situations you must have enough information in your index so that you can apply all restrictions on the fulltext only.
Using Hibernate Search you need only to add some annotations to add the remaining fields to the index, even if they are not used for proper "fulltext", and you should be able to apply all restrictions quite easily, and actually achieving very good performance.
Especially when using indexed enums you have more benefits, for example you could use Search's filters to stack restrictions declaratively.
You're welcome to propose alternative solutions :-)
_________________ Sanne http://in.relation.to/
|