I am indexing fine for my classes and their @IndexedEmbedded collections/relations. However if I introduce a join on the criteria in my scrollable results only 1 record is retrieved for each Collection, and only one result is indexed.
Has anybody come across this problem before?
Code:
FullTextSession fullTextSession = getFullTextSession();
fullTextSession.setCacheMode(CacheMode.IGNORE);
fullTextSession.setFlushMode(FlushMode.MANUAL);
// TODO remove this log info after we've received enough info about indexing times
fullTextSession.purgeAll(getPersistentClass());
Criteria criteria = fullTextSession.createCriteria(getPersistentClass()).setFetchSize(INDEX_BATCH_SIZE);
criteria.setFetchMode("collectionName", FetchMode.JOIN);
ScrollableResults results = criteria.scroll(ScrollMode.FORWARD_ONLY);
int batch = 0;
// commit each result from the db to the index
while (results.next()) {
fullTextSession.index(results.get(0));
// flush to index on the disk to prevent out of memory errors
if (++batch % INDEX_BATCH_SIZE == 0) {
fullTextSession.flushToIndexes();
fullTextSession.clear();
}
}
fullTextSession.getSearchFactory().optimize(getPersistentClass());