Add Indexed annotation on table name on which you want to apply indexing. Over here ItemShop is that table/Entity. @Entity @Indexed public class ItemShop
Run below code to create index on table.
AnnotationConfiguration aConf = new AnnotationConfiguration();
aConf.configure();
Long t = (Long aConf.buildSessionFactory().openSession().createQuery("select count(*) from ItemShop").uniqueResult();
System.out.println("starting loop");
for (int i = 0 ; i< t; i = i+100){
FullTextSession fullTextSession = Search.createFullTextSession(this.getSession());
org.hibernate.Transaction tx = fullTextSession.beginTransaction();
List itemShops = this.getSession().createQuery("from ItemShop").setFirstResult(i).setMaxResults(100).list();
System.out.println("beginTransaction");
tx = fullTextSession.beginTransaction();
for (int j=0;j<itemShops.size();j++)
{
ItemShop itemShop = (ItemShop) itemShops.get(j);
fullTextSession.index(itemShop);
Product p = itemShop.getProduct();
fullTextSession.index(p);
System.out.println("indexed: "+itemShop.getId());
}
tx.commit();
}
Knowledge Exchange about Php Java, Asp.Net, SEO At Narola Infotech