Skip to content

Commit 6301a79

Browse files
committed
Revert "Distinguish harder between content indexes and "other" indexes"
This reverts commit 5b29ca4.
1 parent 5b29ca4 commit 6301a79

50 files changed

Lines changed: 341 additions & 443 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

src/Umbraco.Cms.Search.Core/Configuration/IndexOptions.cs

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,7 @@ public sealed class IndexOptions
99
{
1010
private readonly Dictionary<string, IndexRegistration> _register = [];
1111

12-
public void RegisterIndex<TIndexer, TSearcher>(string indexAlias)
13-
where TIndexer : class, IIndexer
14-
where TSearcher : class, ISearcher
15-
{
16-
ArgumentException.ThrowIfNullOrEmpty("Index alias cannot be empty", nameof(indexAlias));
17-
18-
_register[indexAlias] = new IndexRegistration(indexAlias, typeof(TIndexer), typeof(TSearcher));
19-
}
20-
21-
public void RegisterContentIndex<TIndexer, TSearcher, TContentChangeStrategy>(string indexAlias, params UmbracoObjectTypes[] containedObjectTypes)
12+
public void RegisterIndex<TIndexer, TSearcher, TContentChangeStrategy>(string indexAlias, params UmbracoObjectTypes[] containedObjectTypes)
2213
where TIndexer : class, IIndexer
2314
where TSearcher : class, ISearcher
2415
where TContentChangeStrategy : class, IContentChangeStrategy
@@ -29,15 +20,12 @@ public void RegisterContentIndex<TIndexer, TSearcher, TContentChangeStrategy>(st
2920
throw new ArgumentException($"Index \"{indexAlias}\" must define at least one contained object type", nameof(containedObjectTypes));
3021
}
3122

32-
_register[indexAlias] = new ContentIndexRegistration(indexAlias, typeof(TIndexer), typeof(TSearcher), typeof(TContentChangeStrategy), containedObjectTypes.Distinct());
23+
_register[indexAlias] = new IndexRegistration(indexAlias, containedObjectTypes.Distinct(), typeof(TIndexer), typeof(TSearcher), typeof(TContentChangeStrategy));
3324
}
3425

35-
public ContentIndexRegistration[] GetContentIndexRegistrations()
36-
=> _register.Values.OfType<ContentIndexRegistration>().ToArray();
26+
public IndexRegistration[] GetIndexRegistrations()
27+
=> _register.Values.ToArray();
3728

3829
public IndexRegistration? GetIndexRegistration(string indexAlias)
3930
=> _register.TryGetValue(indexAlias, out IndexRegistration? indexRegistration) ? indexRegistration : null;
40-
41-
public ContentIndexRegistration? GetContentIndexRegistration(string indexAlias)
42-
=> GetIndexRegistration(indexAlias) as ContentIndexRegistration;
4331
}

src/Umbraco.Cms.Search.Core/Controllers/GetAllIndexesApiController.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public GetAllIndexesApiController(
3434
public async Task<IActionResult> Indexes()
3535
{
3636
List<IndexViewModel> indexes = [];
37-
foreach (ContentIndexRegistration indexRegistration in _options.GetContentIndexRegistrations())
37+
foreach (IndexRegistration indexRegistration in _options.GetIndexRegistrations())
3838
{
3939
if (TryGetIndexer(_serviceProvider, indexRegistration.Indexer, _logger, out IIndexer? indexer) is false)
4040
{

src/Umbraco.Cms.Search.Core/Controllers/GetIndexApiController.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ public async Task<IActionResult> Index(string indexAlias)
3939
return BadRequest("The indexAlias parameter must be provided and cannot be empty.");
4040
}
4141

42-
ContentIndexRegistration? indexRegistration = _options.GetContentIndexRegistration(indexAlias);
42+
IndexRegistration? indexRegistration = _options.GetIndexRegistration(indexAlias);
4343
if (indexRegistration is null)
4444
{
4545
return NotFound("The specified index alias was not found.");

src/Umbraco.Cms.Search.Core/Controllers/RebuildIndexApiController.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ public IActionResult Rebuild(string indexAlias)
3232
}
3333

3434
// Check if the index exists before calling the service
35-
ContentIndexRegistration? indexRegistration = _options.GetContentIndexRegistration(indexAlias);
35+
IndexRegistration? indexRegistration = _options.GetIndexRegistration(indexAlias);
3636
if (indexRegistration is null)
3737
{
3838
return NotFound("The specified index alias was not found.");

src/Umbraco.Cms.Search.Core/Models/Configuration/ContentIndexRegistration.cs

Lines changed: 0 additions & 6 deletions
This file was deleted.
Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1-
namespace Umbraco.Cms.Search.Core.Models.Configuration;
1+
using Umbraco.Cms.Core.Models;
22

3-
public record IndexRegistration(string IndexAlias, Type Indexer, Type Searcher);
3+
namespace Umbraco.Cms.Search.Core.Models.Configuration;
4+
5+
public record IndexRegistration(string IndexAlias, IEnumerable<UmbracoObjectTypes> ContainedObjectTypes, Type Indexer, Type Searcher, Type ContentChangeStrategy);

src/Umbraco.Cms.Search.Core/Models/Indexing/ContentIndexInfo.cs renamed to src/Umbraco.Cms.Search.Core/Models/Indexing/IndexInfo.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@
33

44
namespace Umbraco.Cms.Search.Core.Models.Indexing;
55

6-
public record ContentIndexInfo(string IndexAlias, IEnumerable<UmbracoObjectTypes> ContainedObjectTypes, IIndexer Indexer);
6+
public record IndexInfo(string IndexAlias, IEnumerable<UmbracoObjectTypes> ContainedObjectTypes, IIndexer Indexer);

src/Umbraco.Cms.Search.Core/NotificationHandlers/RebuildIndexesNotificationHandler.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ public async Task HandleAsync(LanguageDeletedNotification notification, Cancella
3939
_logger.LogInformation("Rebuilding search indexes after language deletion...");
4040
await _indexDocumentService.DeleteAllAsync();
4141

42-
foreach (ContentIndexRegistration indexRegistration in _options.GetContentIndexRegistrations())
42+
foreach (IndexRegistration indexRegistration in _options.GetIndexRegistrations())
4343
{
4444
if (indexRegistration.ContainedObjectTypes.Contains(UmbracoObjectTypes.Document))
4545
{
@@ -67,7 +67,7 @@ private async Task RebuildByObjectType<T>(IEnumerable<ContentTypeChange<T>> chan
6767
continue;
6868
}
6969

70-
foreach (ContentIndexRegistration indexRegistration in _options.GetContentIndexRegistrations())
70+
foreach (IndexRegistration indexRegistration in _options.GetIndexRegistrations())
7171
{
7272
if (indexRegistration.ContainedObjectTypes.Contains(objectType))
7373
{

src/Umbraco.Cms.Search.Core/Notifications/ContentIndexingNotification.cs renamed to src/Umbraco.Cms.Search.Core/Notifications/IndexingNotification.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,23 +4,23 @@
44

55
namespace Umbraco.Cms.Search.Core.Notifications;
66

7-
public sealed class ContentIndexingNotification : ICancelableNotification
7+
public sealed class IndexingNotification : ICancelableNotification
88
{
9-
public ContentIndexingNotification(
10-
string indexAlias,
9+
public IndexingNotification(
10+
IndexInfo indexInfo,
1111
Guid id,
1212
UmbracoObjectTypes objectType,
1313
IEnumerable<Variation> variations,
1414
IEnumerable<IndexField> fields)
1515
{
16-
IndexAlias = indexAlias;
16+
IndexInfo = indexInfo;
1717
Id = id;
1818
ObjectType = objectType;
1919
Variations = variations;
2020
Fields = fields;
2121
}
2222

23-
public string IndexAlias { get; }
23+
public IndexInfo IndexInfo { get; }
2424

2525
public Guid Id { get; }
2626

src/Umbraco.Cms.Search.Core/Services/ContentIndexing/ContentChangeStrategyBase.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,6 @@ protected async Task EnumerateDescendantsByPath<T>(
6363
while (descendants.Length == ContentEnumerationPageSize);
6464
}
6565

66-
protected void LogIndexRebuildCancellation(ContentIndexInfo indexInfo)
66+
protected void LogIndexRebuildCancellation(IndexInfo indexInfo)
6767
=> _logger.LogInformation("Cancellation requested for rebuild of index: {indexAlias}", indexInfo.IndexAlias);
6868
}

0 commit comments

Comments
 (0)