I am using Hibernate Search 3.0.0 Beta 4. This version for me offers functionality that I'd like to use, which is the "enableFullTextFilter" calls. I followed the instructions as per the example.
I have multiple entities declared in my Hibernate space, but only one entity that has FullTextFilterDef settings.
When searching on that entity using the Filter restriction, the "enableFullTextFilter" call results in a SearchException:
Code:
[WARN] StandardContext[]Exception while dispatching incoming RPC call
com.google.gwt.user.server.rpc.UnexpectedException: Service method 'public abstract net.sf.pdune.client.dto.IssueBriefDTO[] net.sf.pdune.client.services.IssueService.search(java.lang.String,int,int) throws net.sf.pdune.client.UIException' threw an unexpected exception: org.hibernate.search.SearchException: Unkown @FullTextFilter: project
at com.google.gwt.user.server.rpc.RPC.encodeResponseForFailure(RPC.java:268)
at com.google.gwt.user.server.rpc.RPC.invokeAndEncodeResponse(RPC.java:366)
at com.google.gwt.user.server.rpc.RemoteServiceServlet.processCall(RemoteServiceServlet.java:222)
at com.google.gwt.user.server.rpc.RemoteServiceServlet.doPost(RemoteServiceServlet.java:174)
I think this is due to the fact that the SearchFactoryImpl class recreates the filterDefinitions map on each call of bindFilterDefs:
Code:
public class SearchFactoryImpl implements SearchFactoryImplementor {
...
private void bindFilterDefs(XClass mappedXClass) {
filterDefinitions = new HashMap<String, FilterDef>();
...
}
My code where I am declaring the filter:
Code:
@Entity
@Table(name="ISSUE")
@Indexed(index="issue")
@FullTextFilterDef(name = IssueProjectFilterFactory.FILTER_NAME, impl = IssueProjectFilterFactory.class)
@SequenceGenerator( name="ISSUE_SEQ", sequenceName="seq_issue")
public class Issue extends PersistentObject implements Comparable
and the query code:
Code:
org.apache.lucene.search.Query luceneQuery = MultiFieldQueryParser.parse( query, Issue.FIELDS, flags, analyzer );
FullTextQuery fullTextQuery = fullTextSession.createFullTextQuery( luceneQuery, Issue.class );
fullTextQuery.enableFullTextFilter( IssueProjectFilterFactory.FILTER_NAME ).setParameter(
IssueProjectFilterFactory.PARAM_NAME, projects );
Please let me know if I am doing something wrong or whether this is a confirmed bug!