Creates IUmbracoIndexer to decouple lucene from the indexers

This commit is contained in:
Shannon
2018-11-26 11:05:53 +11:00
parent ff2b2893ae
commit 75116e1585
5 changed files with 17 additions and 12 deletions

View File

@@ -59,6 +59,7 @@
<Compile Include="Config\IndexSet.cs" />
<Compile Include="Config\IndexSetCollection.cs" />
<Compile Include="Config\IndexSets.cs" />
<Compile Include="IUmbracoIndexer.cs" />
<Compile Include="UmbracoExamineExtensions.cs" />
<Compile Include="IndexTypes.cs" />
<Compile Include="NoPrefixSimpleFsLockFactory.cs" />

View File

@@ -177,12 +177,6 @@ namespace Umbraco.Examine
/// </summary>
public bool SupportProtectedContent { get; protected set; }
/// <summary>
/// Determines if the manager will call the indexing methods when content is saved or deleted as
/// opposed to cache being updated.
/// </summary>
public bool SupportUnpublishedContent { get; protected set; }
/// <summary>
/// If set this will filter the content items allowed to be indexed
/// </summary>

View File

@@ -57,7 +57,7 @@ namespace Umbraco.Examine
/// An abstract provider containing the basic functionality to be able to query against
/// Umbraco data.
/// </summary>
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
/// </summary>
public bool EnableDefaultEventHandler { get; set; } = true;
/// <summary>
/// When set to true data will not be deleted from the index if the data is being unpublished (not deleted)
/// </summary>
/// <remarks>
/// Generally used only for published content
/// </remarks>
public bool SupportUnpublishedContent { get; protected set; } = false;
/// <summary>
/// the supported indexable types
/// </summary>

View File

@@ -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)

View File

@@ -106,7 +106,7 @@ namespace Umbraco.Web.Search
profilingLogger.Logger.Debug<ExamineComponent>("Examine shutdown registered with MainDom");
var registeredIndexers = examineManager.IndexProviders.Values.OfType<UmbracoExamineIndexer>().Count(x => x.EnableDefaultEventHandler);
var registeredIndexers = examineManager.IndexProviders.Values.OfType<IUmbracoIndexer>().Count(x => x.EnableDefaultEventHandler);
profilingLogger.Logger.Info<ExamineComponent>("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<UmbracoExamineIndexer>())
foreach (var index in _examineManager.IndexProviders.Values.OfType<IUmbracoIndexer>())
{
var searcher = index.GetSearcher();
@@ -762,7 +763,7 @@ namespace Umbraco.Web.Search
examineComponent._examineManager.IndexItems(
valueSet.ToArray(),
examineComponent._examineManager.IndexProviders.Values.OfType<UmbracoExamineIndexer>()
examineComponent._examineManager.IndexProviders.Values.OfType<IUmbracoIndexer>()
//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<UmbracoExamineIndexer>()
examineComponent._examineManager.IndexProviders.Values.OfType<IUmbracoIndexer>()
// 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));
}
}