Hi all,
I’m building an examine query to search for descendants of a page, but I’m running into an issue where query.Execute()
isn’t returning all the results (only 100 of 260).
Version: 13.7.2
ISearchResults does have a TotalItemCount property that has the correct count, but I can’t return all the items. Anyone know where I’m going wrong with this?
public IEnumerable<T> GetDescendantsWithType<T>(IPublishedContent root, string sortField = null, SortType sortType = SortType.String, bool sortAscending = true)
where T : IPublishedContent
{
if (_examineManager.TryGetIndex(UmbracoIndexes.ExternalIndexName, out IIndex index) == false)
{
throw new Exception($"Failed to find {UmbracoIndexes.ExternalIndexName}");
}
var type = typeof(T).Name.ToLower();
var query = index.Searcher.CreateQuery("content").NodeTypeAlias(type);
query.And().Field("path", root.Id.ToString());
if (string.IsNullOrWhiteSpace(sortField) == false)
{
if (sortAscending == true)
{
query.OrderBy(new SortableField(sortField, sortType));
}
else
{
query.OrderByDescending(new SortableField(sortField, sortType));
}
}
ISearchResults searchResults = query.Execute(); //100 results
var testTotalItemCount = searchResults.TotalItemCount; //260 results
return searchResults.GetResults<T>();
}
Thanks