diff --git a/CHANGELOG.md b/CHANGELOG.md
index e3cba6174..9785f5489 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -12,6 +12,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
### Changed
- Update Plex, Jellyfin and Emby movie library scanners to share a significant amount of code
- This should help maintain feature parity going forward
+- Optimize search-index rebuilding to complete 100x faster
### Added
- Add `unavailable` state for Emby movie libraries
diff --git a/ErsatzTV.Application/ErsatzTV.Application.csproj b/ErsatzTV.Application/ErsatzTV.Application.csproj
index 026e7303a..917aa78b5 100644
--- a/ErsatzTV.Application/ErsatzTV.Application.csproj
+++ b/ErsatzTV.Application/ErsatzTV.Application.csproj
@@ -8,7 +8,8 @@
-
+
+
diff --git a/ErsatzTV.Application/Search/Commands/RebuildSearchIndexHandler.cs b/ErsatzTV.Application/Search/Commands/RebuildSearchIndexHandler.cs
index 880e72507..412449dc8 100644
--- a/ErsatzTV.Application/Search/Commands/RebuildSearchIndexHandler.cs
+++ b/ErsatzTV.Application/Search/Commands/RebuildSearchIndexHandler.cs
@@ -1,8 +1,10 @@
-using ErsatzTV.Core;
+using System.Diagnostics;
+using ErsatzTV.Core;
using ErsatzTV.Core.Domain;
using ErsatzTV.Core.Interfaces.Metadata;
using ErsatzTV.Core.Interfaces.Repositories;
using ErsatzTV.Core.Interfaces.Search;
+using Humanizer;
using Microsoft.Extensions.Logging;
namespace ErsatzTV.Application.Search;
@@ -41,12 +43,13 @@ public class RebuildSearchIndexHandler : IRequestHandler itemIds = await _searchRepository.GetItemIdsToIndex();
- await _searchIndex.Rebuild(_searchRepository, itemIds);
+ var sw = Stopwatch.StartNew();
+ await _searchIndex.Rebuild(_searchRepository);
await _configElementRepository.Upsert(ConfigElementKey.SearchIndexVersion, _searchIndex.Version);
+ sw.Stop();
- _logger.LogInformation("Done migrating search index");
+ _logger.LogInformation("Done migrating search index in {Duration}", sw.Elapsed.Humanize());
}
else
{
diff --git a/ErsatzTV.Core.Tests/ErsatzTV.Core.Tests.csproj b/ErsatzTV.Core.Tests/ErsatzTV.Core.Tests.csproj
index 07534ec9c..b7a10f6ef 100644
--- a/ErsatzTV.Core.Tests/ErsatzTV.Core.Tests.csproj
+++ b/ErsatzTV.Core.Tests/ErsatzTV.Core.Tests.csproj
@@ -8,7 +8,7 @@
-
+
@@ -24,7 +24,7 @@
-
+
diff --git a/ErsatzTV.Core/ErsatzTV.Core.csproj b/ErsatzTV.Core/ErsatzTV.Core.csproj
index b87579a62..de909e47f 100644
--- a/ErsatzTV.Core/ErsatzTV.Core.csproj
+++ b/ErsatzTV.Core/ErsatzTV.Core.csproj
@@ -9,7 +9,7 @@
-
+
@@ -21,7 +21,7 @@
runtime; build; native; contentfiles; analyzers; buildtransitive
-
+
diff --git a/ErsatzTV.Core/Interfaces/Repositories/ISearchRepository.cs b/ErsatzTV.Core/Interfaces/Repositories/ISearchRepository.cs
index 691246c5d..50c38625b 100644
--- a/ErsatzTV.Core/Interfaces/Repositories/ISearchRepository.cs
+++ b/ErsatzTV.Core/Interfaces/Repositories/ISearchRepository.cs
@@ -4,10 +4,10 @@ namespace ErsatzTV.Core.Interfaces.Repositories;
public interface ISearchRepository
{
- Task> GetItemIdsToIndex();
Task