Code sample
Retrieve full result set with EPiServer Find
By default only the first ten hits are returned when using EPiServer Find. That number can be increased to a thousand, but not more. Here's an example of how to get *all* hits. Use with caution :)
public IEnumerable<PageData> GetPages()
{
int totalNumberOfPages;
var query = SearchClient.Instance.Search<PageData>()
.Take(1000);
var batch = query.GetContentResult();
foreach (var page in batch)
{
yield return page;
}
totalNumberOfPages = batch.TotalMatching;
var nextBatchFrom = 1000;
while (nextBatchFrom < totalNumberOfPages)
{
batch = query.Skip(nextBatchFrom).GetContentResult();
foreach (var page in batch)
{
yield return page;
}
nextBatchFrom += 1000;
}
}
Similar articles
- Building a search page for an EPiServer site using Truffler
- Building a search page for an EPiServer site using Truffler - Part 2
- Cool new features in the Truffler .NET API
- Related content with EPiServer Find
- Wildcard queries with EPiServer Find
- Truffler update – dotting the i’s and crossing the t’s
- Introducing Truffler – Advanced search made easy
- New in EPiServer Find – Unified Search