-->
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.  [ 4 posts ] 
Author Message
 Post subject: creating initial index on lots of different objects
PostPosted: Thu Dec 03, 2009 6:41 am 
Regular
Regular

Joined: Thu Nov 26, 2009 8:45 am
Posts: 78
Hi,

i got a lot of different Classes here, i annotated to be indexed. I tested creating indexes with the
Code:
fSession.index(a);

with a beeing an object which is type is well known. How can i iterate over all my objects (of different types) to create an initial index? Do i have to query hibernate for all of the types manually or am i missing something?


Top
 Profile  
 
 Post subject: Re: creating initial index on lots of different objects
PostPosted: Thu Dec 03, 2009 7:35 am 
Hibernate Team
Hibernate Team

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

the answer to your question depends a little on the version of Hibernate Search you are using. If you are using a 3.1.x version you basically have to know your indexed entities and for each indexed type do a batch indexing as described in the Manual Indexing chapter of the documentation.

If you are using the 3.2.x (currently in beta) version of Search you can leverage from the new MassIndexer API. In the simplest case your code would look like this:
Code:
fulltextSession.createIndexer().startAndWait()


--Hardy


Top
 Profile  
 
 Post subject: Re: creating initial index on lots of different objects
PostPosted: Thu Dec 03, 2009 7:52 am 
Regular
Regular

Joined: Thu Nov 26, 2009 8:45 am
Posts: 78
i currently have to use 3.0.1 (due to internal restrictions on hibernate), so i have to write a index loop (like it is described in the manual) for each of my (approximately) 100 DAOs?


Top
 Profile  
 
 Post subject: Re: creating initial index on lots of different objects
PostPosted: Fri Dec 04, 2009 7:32 am 
Hibernate Team
Hibernate Team

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

if you already have a list of all indexed classes you can just use the batch indexing code as described in the documentation. I must say having so many different indexed classes is quite unusual. At least I haven't heard of many such usecases.

Of course you can always scan your classes for all classes annotated with @Indexed.

There is one other way using the current API, but it involves a cast. Maybe that's good enough for you. From your FullTextSession you can do

Code:
SearchFactory factory = fullTextSession.getSearchFactory();
SearchFactoryImpl specificFactory = (SearchFactoryImpl) factory;
Set<Class> indexedClasses = specificFactory.getDocumentBuildersIndexedEntities().keySet();


--Hardy


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