-->
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.  [ 1 post ] 
Author Message
 Post subject: Filtering collection elements while indexing
PostPosted: Tue Mar 12, 2013 1:30 pm 
Newbie

Joined: Tue Mar 12, 2013 12:54 pm
Posts: 1
Hello,

Is there any way to filter elements of children collection during indexing ?

Example :
Code:
@Index
class Parent {

   @IndexedEmbedded
   Set<Child> children;
}


class Child {
   /* A lot of properties */
}


When I create or update a Parent instance I want to index only some children elements.

The only working way I found for now is to use @ClassBridge. I give the code because it may interests some others people but I just can't use this solution because my Child class already have a lot of indexed properties (annoted with @Field, multi times for some of them with different analysers) and it works fine (except that now I want to filter some of them) and I don't want to write the whole equivalent code in a lot of Brigde classes (1 brigde / per collection / per analyser).

Code:
@ClassBridge(impl = ChildBridge.class, analyzer=@Analyzer(definition = "some_analyser_name"))
class Child {
   /* A lot of properties */
}


class ChildBridge {

   public void set(String name, Object value, Document document, LuceneOptions luceneOptions) {
      Child child = (Child) value;
      if (skipIndex(child)) {
         return;
      }else{
         //manually index each property   
      }
   }
   
   private boolean skipIndex(Child child) {
      /* some conditions */
   }

}


Please forgive me for my mistakes, I am a french guy with a poor english :)


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

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.