From 0356e5a2247100f0f60bd8b54f21980523720621 Mon Sep 17 00:00:00 2001 From: Shannon Date: Mon, 7 Jan 2019 18:16:06 +1100 Subject: [PATCH] Updates to latest examine, fixes issue with rebuilding indexes in the back office seeming to timeout but was a problem with the callback registration in examine --- build/NuSpecs/UmbracoCms.Web.nuspec | 2 +- src/Umbraco.Examine/Umbraco.Examine.csproj | 2 +- src/Umbraco.Examine/UmbracoContentIndex.cs | 34 ++++++++++++---------- src/Umbraco.Examine/UmbracoExamineIndex.cs | 4 +-- src/Umbraco.Tests/Umbraco.Tests.csproj | 2 +- src/Umbraco.Web.UI/Umbraco.Web.UI.csproj | 2 +- src/Umbraco.Web/Umbraco.Web.csproj | 2 +- 7 files changed, 26 insertions(+), 22 deletions(-) diff --git a/build/NuSpecs/UmbracoCms.Web.nuspec b/build/NuSpecs/UmbracoCms.Web.nuspec index 51d7e3b8d0..35e79d8127 100644 --- a/build/NuSpecs/UmbracoCms.Web.nuspec +++ b/build/NuSpecs/UmbracoCms.Web.nuspec @@ -25,7 +25,7 @@ - + diff --git a/src/Umbraco.Examine/Umbraco.Examine.csproj b/src/Umbraco.Examine/Umbraco.Examine.csproj index 9191f7b38d..a68131da0d 100644 --- a/src/Umbraco.Examine/Umbraco.Examine.csproj +++ b/src/Umbraco.Examine/Umbraco.Examine.csproj @@ -48,7 +48,7 @@ - + diff --git a/src/Umbraco.Examine/UmbracoContentIndex.cs b/src/Umbraco.Examine/UmbracoContentIndex.cs index ce4b410bb3..a9e2c72cb6 100644 --- a/src/Umbraco.Examine/UmbracoContentIndex.cs +++ b/src/Umbraco.Examine/UmbracoContentIndex.cs @@ -92,8 +92,8 @@ namespace Umbraco.Examine //these are the invalid items so we'll delete them //since the path is not valid we need to delete this item in case it exists in the index already and has now //been moved to an invalid parent. - foreach (var i in group) - base.PerformDeleteFromIndex(i.Id, args => { /*noop*/ }); + + base.PerformDeleteFromIndex(group.Select(x => x.Id), args => { /*noop*/ }); } else { @@ -118,24 +118,28 @@ namespace Umbraco.Examine /// When a content node is deleted, we also need to delete it's children from the index so we need to perform a /// custom Lucene search to find all decendents and create Delete item queues for them too. /// - /// ID of the node to delete + /// ID of the node to delete /// - protected override void PerformDeleteFromIndex(string nodeId, Action onComplete) + protected override void PerformDeleteFromIndex(IEnumerable itemIds, Action onComplete) { - //find all descendants based on path - var descendantPath = $@"\-1\,*{nodeId}\,*"; - var rawQuery = $"{IndexPathFieldName}:{descendantPath}"; - var searcher = GetSearcher(); - var c = searcher.CreateQuery(); - var filtered = c.NativeQuery(rawQuery); - var results = filtered.Execute(); + var idsAsList = itemIds.ToList(); + foreach (var nodeId in idsAsList) + { + //find all descendants based on path + var descendantPath = $@"\-1\,*{nodeId}\,*"; + var rawQuery = $"{IndexPathFieldName}:{descendantPath}"; + var searcher = GetSearcher(); + var c = searcher.CreateQuery(); + var filtered = c.NativeQuery(rawQuery); + var results = filtered.Execute(); - ProfilingLogger.Debug(GetType(), "DeleteFromIndex with query: {Query} (found {TotalItems} results)", rawQuery, results.TotalItemCount); + ProfilingLogger.Debug(GetType(), "DeleteFromIndex with query: {Query} (found {TotalItems} results)", rawQuery, results.TotalItemCount); - //need to queue a delete item for each one found - QueueIndexOperation(results.Select(r => new IndexOperation(new ValueSet(r.Id), IndexOperationType.Delete))); + //need to queue a delete item for each one found + QueueIndexOperation(results.Select(r => new IndexOperation(new ValueSet(r.Id), IndexOperationType.Delete))); + } - base.PerformDeleteFromIndex(nodeId, onComplete); + base.PerformDeleteFromIndex(idsAsList, onComplete); } } diff --git a/src/Umbraco.Examine/UmbracoExamineIndex.cs b/src/Umbraco.Examine/UmbracoExamineIndex.cs index 6804d199f8..24952050da 100644 --- a/src/Umbraco.Examine/UmbracoExamineIndex.cs +++ b/src/Umbraco.Examine/UmbracoExamineIndex.cs @@ -94,13 +94,13 @@ namespace Umbraco.Examine /// /// This check is required since the base examine lib will try to rebuild on startup /// - protected override void PerformDeleteFromIndex(string nodeId, Action onComplete) + protected override void PerformDeleteFromIndex(IEnumerable itemIds, Action onComplete) { if (CanInitialize()) { using (new SafeCallContext()) { - base.PerformDeleteFromIndex(nodeId, onComplete); + base.PerformDeleteFromIndex(itemIds, onComplete); } } } diff --git a/src/Umbraco.Tests/Umbraco.Tests.csproj b/src/Umbraco.Tests/Umbraco.Tests.csproj index af42e2503f..bed1281bf8 100644 --- a/src/Umbraco.Tests/Umbraco.Tests.csproj +++ b/src/Umbraco.Tests/Umbraco.Tests.csproj @@ -77,7 +77,7 @@ - + 1.8.9 diff --git a/src/Umbraco.Web.UI/Umbraco.Web.UI.csproj b/src/Umbraco.Web.UI/Umbraco.Web.UI.csproj index 61e31d2d3e..2fc199d06a 100644 --- a/src/Umbraco.Web.UI/Umbraco.Web.UI.csproj +++ b/src/Umbraco.Web.UI/Umbraco.Web.UI.csproj @@ -88,7 +88,7 @@ - + diff --git a/src/Umbraco.Web/Umbraco.Web.csproj b/src/Umbraco.Web/Umbraco.Web.csproj index 3ac5ab9f11..7a695ff4ef 100755 --- a/src/Umbraco.Web/Umbraco.Web.csproj +++ b/src/Umbraco.Web/Umbraco.Web.csproj @@ -63,7 +63,7 @@ - + 2.6.2.25