-->
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.  [ 3 posts ] 
Author Message
 Post subject: Avoiding querying @IndexedEmbedded fields during index init
PostPosted: Thu Nov 26, 2015 12:44 pm 
Newbie

Joined: Thu Nov 26, 2015 11:34 am
Posts: 2
Hello,

We are using Hibernate Search (Hibernate 4.3.7 and Hibernate Search 4.5.1) in our system and we're using MassIndexer in order to initialize the index.
Our model looks approximately like this:
Code:
@Entity
@AccessType(AccessType.FIELD)
@Indexed
public class A {
   @Id
   private Long id;

   @ManyToOne(fetch = FetchType.LAZY)
   @IndexedEmbedded(includePaths = "id", indexNullAs = IndexedEmbedded.DEFAULT_NULL_TOKEN)
   private B b;
}

@Entity
@AccessType(AccessType.FIELD)
public class B {
   @Id
   private Long id;

   private String name;
}

The problem is that when the index is being initialized, objects of class B are being fetched from the database although we need only an id from them in this case. Because of having to perform other actions after fetching objects of B from the database, our index initialization time increases dramatically.

What we've tried so far is doing a workaround like this
Code:
@ManyToOne(fetch = FetchType.LAZY)
@Field(index = Index.NO, bridge = @FieldBridge(impl = FieldBridgeImpl.class))
private B b;

@Field
public Long getBId() {
   return b != null ? b.getId() : null;
}
but that didn't seem to help.

The javadoc of MassIndexer says that 'all indexed entities and their indexedEmbedded properties are scrolled from database'. So my question is - is there any way of stopping the indexer from querying the database in case we require only an id from an object (or even nothing at all if we just have to know whether it's null or not)? Or am I missing something here?


Top
 Profile  
 
 Post subject: Re: Avoiding querying @IndexedEmbedded fields during index init
PostPosted: Fri Nov 27, 2015 4:44 am 
Hibernate Team
Hibernate Team

Joined: Sat Jan 24, 2009 12:46 pm
Posts: 388
Hi Dmitry,

That's an interesting optimization, but we don't provide it yet. I've filed https://hibernate.atlassian.net/browse/HSEARCH-2057 for this, I think it'd be a nice addition. Maybe you'd be interested in helping out with implementing it?

Cheers,

--Gunnar

_________________
Visit my blog at http://musingsofaprogrammingaddict.blogspot.com/


Top
 Profile  
 
 Post subject: Re: Avoiding querying @IndexedEmbedded fields during index init
PostPosted: Fri Nov 27, 2015 6:58 am 
Newbie

Joined: Thu Nov 26, 2015 11:34 am
Posts: 2
Hi Gunnar,

Thanks for the answer. I'm not sure I'll be able to provide a fix but I'd be glad to try. I'll check it out and see what I can do.


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