diff --git a/src/Umbraco.Examine/Umbraco.Examine.csproj b/src/Umbraco.Examine/Umbraco.Examine.csproj index 98ad566738..db3570d380 100644 --- a/src/Umbraco.Examine/Umbraco.Examine.csproj +++ b/src/Umbraco.Examine/Umbraco.Examine.csproj @@ -59,6 +59,7 @@ + diff --git a/src/Umbraco.Examine/UmbracoContentIndexer.cs b/src/Umbraco.Examine/UmbracoContentIndexer.cs index b4eeeac3d9..541ecd1b2b 100644 --- a/src/Umbraco.Examine/UmbracoContentIndexer.cs +++ b/src/Umbraco.Examine/UmbracoContentIndexer.cs @@ -177,12 +177,6 @@ namespace Umbraco.Examine /// public bool SupportProtectedContent { get; protected set; } - /// - /// Determines if the manager will call the indexing methods when content is saved or deleted as - /// opposed to cache being updated. - /// - public bool SupportUnpublishedContent { get; protected set; } - /// /// If set this will filter the content items allowed to be indexed /// diff --git a/src/Umbraco.Examine/UmbracoExamineIndexer.cs b/src/Umbraco.Examine/UmbracoExamineIndexer.cs index d5c9adea77..fd56ac7fc4 100644 --- a/src/Umbraco.Examine/UmbracoExamineIndexer.cs +++ b/src/Umbraco.Examine/UmbracoExamineIndexer.cs @@ -57,7 +57,7 @@ namespace Umbraco.Examine /// An abstract provider containing the basic functionality to be able to query against /// Umbraco data. /// - public abstract class UmbracoExamineIndexer : LuceneIndexer + public abstract class UmbracoExamineIndexer : LuceneIndexer, IUmbracoIndexer { // note // wrapping all operations that end up calling base.SafelyProcessQueueItems in a safe call @@ -191,6 +191,14 @@ namespace Umbraco.Examine /// public bool EnableDefaultEventHandler { get; set; } = true; + /// + /// When set to true data will not be deleted from the index if the data is being unpublished (not deleted) + /// + /// + /// Generally used only for published content + /// + public bool SupportUnpublishedContent { get; protected set; } = false; + /// /// the supported indexable types /// diff --git a/src/Umbraco.Web/PropertyEditors/GridPropertyEditor.cs b/src/Umbraco.Web/PropertyEditors/GridPropertyEditor.cs index 774c2da35f..9b5443c649 100644 --- a/src/Umbraco.Web/PropertyEditors/GridPropertyEditor.cs +++ b/src/Umbraco.Web/PropertyEditors/GridPropertyEditor.cs @@ -25,6 +25,7 @@ namespace Umbraco.Web.PropertyEditors : base(logger) { } + //TODO: Change this to use a native way of indexing data: https://github.com/umbraco/Umbraco-CMS/issues/3531 internal void DocumentWriting(object sender, Examine.LuceneEngine.DocumentWritingEventArgs e) { foreach (var value in e.ValueSet.Values) diff --git a/src/Umbraco.Web/Search/ExamineComponent.cs b/src/Umbraco.Web/Search/ExamineComponent.cs index 867132b23f..b355f6bd91 100644 --- a/src/Umbraco.Web/Search/ExamineComponent.cs +++ b/src/Umbraco.Web/Search/ExamineComponent.cs @@ -106,7 +106,7 @@ namespace Umbraco.Web.Search profilingLogger.Logger.Debug("Examine shutdown registered with MainDom"); - var registeredIndexers = examineManager.IndexProviders.Values.OfType().Count(x => x.EnableDefaultEventHandler); + var registeredIndexers = examineManager.IndexProviders.Values.OfType().Count(x => x.EnableDefaultEventHandler); profilingLogger.Logger.Info("Adding examine event handlers for {RegisteredIndexers} index providers.", registeredIndexers); @@ -198,6 +198,7 @@ namespace Umbraco.Web.Search } } + //TODO: Change this to use a native way of indexing data: https://github.com/umbraco/Umbraco-CMS/issues/3531 private static void BindGridToExamine(ILogger logger, IExamineManager examineManager, IEnumerable propertyEditors) { //bind the grid property editors - this is a hack until http://issues.umbraco.org/issue/U4-8437 @@ -369,7 +370,7 @@ namespace Umbraco.Web.Search //Delete all content of this content/media/member type that is in any content indexer by looking up matched examine docs foreach (var id in ci.Value.removedIds) { - foreach (var index in _examineManager.IndexProviders.Values.OfType()) + foreach (var index in _examineManager.IndexProviders.Values.OfType()) { var searcher = index.GetSearcher(); @@ -762,7 +763,7 @@ namespace Umbraco.Web.Search examineComponent._examineManager.IndexItems( valueSet.ToArray(), - examineComponent._examineManager.IndexProviders.Values.OfType() + examineComponent._examineManager.IndexProviders.Values.OfType() //ensure that only the providers are flagged to listen execute .Where(x => x.EnableDefaultEventHandler)); } @@ -790,10 +791,10 @@ namespace Umbraco.Web.Search { examineComponent._examineManager.DeleteFromIndexes( id.ToString(CultureInfo.InvariantCulture), - examineComponent._examineManager.IndexProviders.Values.OfType() + examineComponent._examineManager.IndexProviders.Values.OfType() // if keepIfUnpublished == true then only delete this item from indexes not supporting unpublished content, // otherwise if keepIfUnpublished == false then remove from all indexes - .Where(x => keepIfUnpublished == false || (x is UmbracoContentIndexer && ((UmbracoContentIndexer)x).SupportUnpublishedContent == false)) + .Where(x => keepIfUnpublished == false || x.SupportUnpublishedContent == false) .Where(x => x.EnableDefaultEventHandler)); } }