Pagelet[] mainPagelets = pages[0].getPagelets("main");
Pagelet titlePagelet = new PageletImpl(mainPagelets[0].getModule(), mainPagelets[0].getIdentifier());
Pagelet imagePagelet = new PageletImpl(mainPagelets[1].getModule(), mainPagelets[1].getIdentifier());
// Search for pages containing a pagelet (pages 1 and 2)
SearchQuery q = new SearchQueryImpl(site).withPagelet(titlePagelet);
assertEquals(2, idx.getByQuery(q).getDocumentCount());
// Search for pages containing an image pagelet (only page 1)
q = new SearchQueryImpl(site).withPagelet(imagePagelet);
assertEquals(1, idx.getByQuery(q).getDocumentCount());