Hibernate Search, filter out object with the highest value
Hi i have a EntityObject like this
public class Adm{
private String id;
private String version;
private String name;
private String mimetype;
...
开发者_运维技巧...
...
}
I would like to add an filter out all objects with the highest version of those objects with the same name. Anyone got any idea how todo this, with a filter or when creating the query?
I use Hibernate Search Version 3.3.0.
//Trind
The way to do filtering in Search is via FullTextFilters. See http://docs.jboss.org/hibernate/stable/search/reference/en-US/html_single/#query-filter You can pass parameters to the filter when you enable them, eg
fullTextQuery.enableFullTextFilter("version").setParameter( "max", 1001 );
You can pass as many parameters you like and also pass any parameter type you want (you will just have to cast appropriately in the filter implementation). You would probably need another query to determine the max values. Maybe a HQL or Criteria query after all. Within the Filter you could use a NumericRangeQuery. Of course this all depends on your domain model. You haven't included the Hibernate Search annotations and the Hibernate Search query you are trying to run. Also is the max version something you can determine beforehand and cache? Hope, this gives you some pointers.
精彩评论