Allow empty valuesets to be indexed so the back-offce does not hang when rebuilding empty indexes

(cherry picked from commit 88ff05a836)
This commit is contained in:
Justin Neville
2022-11-17 15:04:25 +00:00
committed by Sebastiaan Janssen
parent 3bd9da00cc
commit 04be6889ab
3 changed files with 29 additions and 41 deletions

View File

@@ -99,15 +99,12 @@ public class ContentIndexPopulator : IndexPopulator<IUmbracoContentIndex>
{
content = _contentService.GetPagedDescendants(contentParentId, pageIndex, pageSize, out _).ToArray();
if (content.Length > 0)
{
var valueSets = _contentValueSetBuilder.GetValueSets(content).ToList();
var valueSets = _contentValueSetBuilder.GetValueSets(content).ToList();
// ReSharper disable once PossibleMultipleEnumeration
foreach (IIndex index in indexes)
{
index.IndexItems(valueSets);
}
// ReSharper disable once PossibleMultipleEnumeration
foreach (IIndex index in indexes)
{
index.IndexItems(valueSets);
}
pageIndex++;
@@ -127,35 +124,32 @@ public class ContentIndexPopulator : IndexPopulator<IUmbracoContentIndex>
// note: We will filter for published variants in the validator
content = _contentService.GetPagedDescendants(contentParentId, pageIndex, pageSize, out _, PublishedQuery, Ordering.By("Path")).ToArray();
if (content.Length > 0)
var indexableContent = new List<IContent>();
foreach (IContent item in content)
{
var indexableContent = new List<IContent>();
foreach (IContent item in content)
if (item.Level == 1)
{
if (item.Level == 1)
// first level pages are always published so no need to filter them
indexableContent.Add(item);
publishedPages.Add(item.Id);
}
else
{
if (publishedPages.Contains(item.ParentId))
{
// first level pages are always published so no need to filter them
indexableContent.Add(item);
// only index when parent is published
publishedPages.Add(item.Id);
}
else
{
if (publishedPages.Contains(item.ParentId))
{
// only index when parent is published
publishedPages.Add(item.Id);
indexableContent.Add(item);
}
indexableContent.Add(item);
}
}
}
var valueSets = _contentValueSetBuilder.GetValueSets(indexableContent.ToArray()).ToList();
var valueSets = _contentValueSetBuilder.GetValueSets(indexableContent.ToArray()).ToList();
foreach (IIndex index in indexes)
{
index.IndexItems(valueSets);
}
foreach (IIndex index in indexes)
{
index.IndexItems(valueSets);
}
pageIndex++;

View File

@@ -59,13 +59,10 @@ public class MediaIndexPopulator : IndexPopulator<IUmbracoContentIndex>
{
media = _mediaService.GetPagedDescendants(mediaParentId, pageIndex, pageSize, out _).ToArray();
if (media.Length > 0)
// ReSharper disable once PossibleMultipleEnumeration
foreach (IIndex index in indexes)
{
// ReSharper disable once PossibleMultipleEnumeration
foreach (IIndex index in indexes)
{
index.IndexItems(_mediaValueSetBuilder.GetValueSets(media));
}
index.IndexItems(_mediaValueSetBuilder.GetValueSets(media));
}
pageIndex++;

View File

@@ -32,13 +32,10 @@ public class MemberIndexPopulator : IndexPopulator<IUmbracoMemberIndex>
{
members = _memberService.GetAll(pageIndex, pageSize, out _).ToArray();
if (members.Length > 0)
// ReSharper disable once PossibleMultipleEnumeration
foreach (IIndex index in indexes)
{
// ReSharper disable once PossibleMultipleEnumeration
foreach (IIndex index in indexes)
{
index.IndexItems(_valueSetBuilder.GetValueSets(members));
}
index.IndexItems(_valueSetBuilder.GetValueSets(members));
}
pageIndex++;