-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: How to apply enableFullTextFilter to instances of one class
PostPosted: Tue Oct 13, 2009 12:19 am 
Newbie

Joined: Tue Oct 13, 2009 12:10 am
Posts: 1
Hi,

I'm performing a full text search of multiple classes in one query:
Code:
FullTextQuery fullTextQuery = fullTextSession.createFullTextQuery(luceneQuery, Class1.class, Class2.class);

fullTextQuery.enableFullTextFilter("Class1.available");
fullTextQuery.enableFullTextFilter("Class2.visible");

fullTextQuery.list();


Each class defines a filter that should only apply to it and not any other classes. The problem I'm having is that the results of both classes are being filtered by both filters.

Does anyone know a way to work around this while still only doing one query? Would something like the following work?

Code:
fullTextQuery.enableFullTextFilter("Class1.available").setParameter('type', Class1.class);


If so, how would I modify the following filter factory to take that parameter and use it to only filter out instances of that type?

Code:
    public static class NotDeletedFilter extends QueryWrapperFilter {
        public NotDeletedFilter() {
            super(new TermQuery(new Term("deleted", "false")));
        }
    }


thanks


Top
 Profile  
 
 Post subject: Re: How to apply enableFullTextFilter to instances of one class
PostPosted: Tue Oct 13, 2009 3:58 am 
Hibernate Team
Hibernate Team

Joined: Thu Apr 05, 2007 5:52 am
Posts: 1689
Location: Sweden
Hi,

You cannot turn on/off a filter based on a class type. The result of your query is passed through all enabled filters.

How to set parameters in a filter is described in the online manual - http://docs.jboss.org/hibernate/stable/ ... e/#d0e2970

Not sure though whether setting a parameter will help so. You would have to work with boolean queries. For example, the first filter would have to to the following: "(type:Class1 AND <whatever other condition you want to filter on>) OR (type: NOT Class1)" .

I am wondering whether Filters is the right solution for your problem?

--Hardy


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.