-->
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.  [ 5 posts ] 
Author Message
 Post subject: Soft deletes and MassIndexer
PostPosted: Tue Jan 10, 2012 6:24 am 
Newbie

Joined: Tue Jan 10, 2012 4:07 am
Posts: 6
Hi everybody,
Is it possible to customise MassIndexer to not index all entities of given type but only those that aren't soft deleted? In my case soft deleted entities are entities that have 'removed' field set to true.
If MassIndexer uses FullTextIndexEventListener then this question is related to https://forum.hibernate.org/viewtopic.php?f=9&t=1014095 and below code may help:
Code:
public class SoftDeleteFullTextIndexEventListener extends FullTextIndexEventListener {

    private static final long serialVersionUID = 9149462110169911449L;

    public SoftDeleteFullTextIndexEventListener(Installation installation) {
        super(installation);
    }
   
    public void onPostInsert(PostInsertEvent event) {
        if ( used ) {
            final Object entity = event.getEntity();
            if ( entity != null && entity instanceof SoftRemovable && ((SoftRemovable) entity).isRemoved()) {
                // entity is marked as removed so don't index
                return;
            } else {
                super.onPostInsert(event);
            }
        }
    }

}


Top
 Profile  
 
 Post subject: Re: Soft deletes and MassIndexer
PostPosted: Wed Jan 11, 2012 5:22 am 
Hibernate Team
Hibernate Team

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

there is not configuration in the mass indexer which allows you to do this. The issue this relates to is HSEARCH-471.

Customizing FullTextIndexEventListener is one solution, the other is to index all data and use filters.

--Hardy


Top
 Profile  
 
 Post subject: Re: Soft deletes and MassIndexer
PostPosted: Wed Jan 11, 2012 6:10 am 
Newbie

Joined: Tue Jan 10, 2012 4:07 am
Posts: 6
But in hibernate 3.6.x and hibernate search 3.4.x extending FullTextIndexEventListener is no more a solution, as far as I understand this: https://forum.hibernate.org/viewtopic.php?f=9&t=1010513. If I use filter search index will grow over the time and contain useless data which can lower the performance. I'll try with custom LuceneBackendQueueProcessorFactory.


Top
 Profile  
 
 Post subject: Re: Soft deletes and MassIndexer
PostPosted: Thu Jan 12, 2012 2:56 am 
Newbie

Joined: Tue Jan 10, 2012 4:07 am
Posts: 6
It seams that MassIndexer doesn't use FullTextIndexEventListener (at least the custom one set by hibernate.ejb.event.post-*) or hibernate.search.worker.backend.
MassIndexer has dedicated backend which can be set using hibernate.search.batchbackend property.

Thanks for your help Hardy!


Top
 Profile  
 
 Post subject: Re: Soft deletes and MassIndexer
PostPosted: Thu Jan 12, 2012 4:52 am 
Hibernate Team
Hibernate Team

Joined: Thu Apr 05, 2007 5:52 am
Posts: 1689
Location: Sweden
No worries.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 5 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.