Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp
Hibernate version:
3.2.6 GA
Mapping documents:
Code:
@Indexed(index="User")
public class User implements UserDetails {
private static final long serialVersionUID = 5636489207599885697L;
@DocumentId
private Integer id;
protected Status status;
@Field(index=Index.TOKENIZED, store=Store.YES)
@Analyzer(impl=KeywordAnalyzer.class)
@Boost(value=2)
protected String username;
@Field(index=Index.TOKENIZED, store=Store.YES)
@Analyzer(impl=KeywordAnalyzer.class)
@Boost(value=2)
protected String email;
protected String password;
@Field(index=Index.TOKENIZED, store=Store.YES)
@Analyzer(impl=KeywordAnalyzer.class)
@Boost(value=2)
protected String firstname;
@Field(index=Index.TOKENIZED, store=Store.YES)
@Analyzer(impl=KeywordAnalyzer.class)
@Boost(value=2)
protected String lastname;
}
Code between sessionFactory.openSession() and session.close():Code:
public void batchProcessUserIndex()
{
Session session = this.getHibernateTemplate().getSessionFactory().getCurrentSession();
FullTextSession fullTextSession = Search.createFullTextSession(session);
ScrollableResults scr = fullTextSession.createCriteria(User.class).scroll(ScrollMode.FORWARD_ONLY);
while (scr.next())
{
fullTextSession.index(scr.get(0));
}
}
I am using aop and transaction advice.
here is my setting
Code:
<tx:method name="batchProcessUserIndex" propagation="SUPPORTS" isolation="READ_UNCOMMITTED"/>
Code:
<hibernate-configuration>
<session-factory>
<event type="post-update">
<listener class="org.hibernate.search.event.FullTextIndexEventListener"/>
</event>
<event type="post-insert">
<listener class="org.hibernate.search.event.FullTextIndexEventListener"/>
</event>
<event type="post-delete">
<listener class="org.hibernate.search.event.FullTextIndexEventListener"/>
</event>
</session-factory>
</hibernate-configuration>
here is my test class.
i created a class which extends AbstractSpringTransactionalTestCase and i have test case which test batchProcessUserIndex.
The process takes about 3 minutes to run over large amount of data. However when i look at actual directory, the size of segments and file data is like 1 kb. very small. The database contains over 100,000 users.
Thanks.