CacheQuery cacheQuery = Search.getSearchManager(cache).getQuery(luceneQuery)
.maxResults(1);
Assert.assertEquals(3, cacheQuery.getResultSize()); // NOTE: getResultSize() ignores pagination (maxResults, firstResult)
Assert.assertEquals(1, cacheQuery.list().size());
ResultIterator eagerIterator = cacheQuery.iterator(new FetchOptions().fetchMode(FetchOptions.FetchMode.EAGER));
try {
Assert.assertEquals(1, countElements(eagerIterator));
} finally {
eagerIterator.close();
}
ResultIterator lazyIterator = cacheQuery.iterator(new FetchOptions().fetchMode(FetchOptions.FetchMode.LAZY));
try {
Assert.assertEquals(1, countElements(lazyIterator));
} finally {
lazyIterator.close();
}