From 7d5cd229d48cc971eba776bd2b2770fb0e6ae0ca Mon Sep 17 00:00:00 2001 From: Jason Dove <1695733+jasongdove@users.noreply.github.com> Date: Tue, 30 Jan 2024 16:50:57 -0600 Subject: [PATCH] add show_studio search field (#1584) --- CHANGELOG.md | 1 + .../Data/Repositories/SearchRepository.cs | 14 ++++++++++++++ .../Search/ElasticSearchIndex.cs | 5 ++++- .../Search/LuceneSearchIndex.cs | 13 ++++++++++++- .../Search/Models/ElasticSearchItem.cs | 3 +++ ErsatzTV/Program.cs | 3 +-- 6 files changed, 35 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 53a55936..4d47d80f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,7 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). ## [Unreleased] +- Add `show_studio` to search index for seasons and episodes ## [0.8.5-beta] - 2024-01-30 ### Added diff --git a/ErsatzTV.Infrastructure/Data/Repositories/SearchRepository.cs b/ErsatzTV.Infrastructure/Data/Repositories/SearchRepository.cs index 81382390..db4db437 100644 --- a/ErsatzTV.Infrastructure/Data/Repositories/SearchRepository.cs +++ b/ErsatzTV.Infrastructure/Data/Repositories/SearchRepository.cs @@ -61,6 +61,10 @@ public class SearchRepository : ISearchRepository .ThenInclude(s => s.Show) .ThenInclude(s => s.ShowMetadata) .ThenInclude(s => s.Tags) + .Include(mi => (mi as Episode).Season) + .ThenInclude(s => s.Show) + .ThenInclude(s => s.ShowMetadata) + .ThenInclude(s => s.Studios) .Include(mi => (mi as Season).SeasonMetadata) .ThenInclude(sm => sm.Genres) .Include(mi => (mi as Season).SeasonMetadata) @@ -77,6 +81,9 @@ public class SearchRepository : ISearchRepository .Include(mi => (mi as Season).Show) .ThenInclude(sm => sm.ShowMetadata) .ThenInclude(sm => sm.Tags) + .Include(mi => (mi as Season).Show) + .ThenInclude(sm => sm.ShowMetadata) + .ThenInclude(sm => sm.Studios) .Include(mi => (mi as Show).ShowMetadata) .ThenInclude(mm => mm.Genres) .Include(mi => (mi as Show).ShowMetadata) @@ -231,6 +238,10 @@ public class SearchRepository : ISearchRepository .ThenInclude(s => s.Show) .ThenInclude(s => s.ShowMetadata) .ThenInclude(s => s.Tags) + .Include(mi => (mi as Episode).Season) + .ThenInclude(s => s.Show) + .ThenInclude(s => s.ShowMetadata) + .ThenInclude(s => s.Studios) .Include(mi => (mi as Season).SeasonMetadata) .ThenInclude(sm => sm.Genres) .Include(mi => (mi as Season).SeasonMetadata) @@ -247,6 +258,9 @@ public class SearchRepository : ISearchRepository .Include(mi => (mi as Season).Show) .ThenInclude(sm => sm.ShowMetadata) .ThenInclude(sm => sm.Tags) + .Include(mi => (mi as Season).Show) + .ThenInclude(sm => sm.ShowMetadata) + .ThenInclude(sm => sm.Studios) .Include(mi => (mi as Show).ShowMetadata) .ThenInclude(mm => mm.Genres) .Include(mi => (mi as Show).ShowMetadata) diff --git a/ErsatzTV.Infrastructure/Search/ElasticSearchIndex.cs b/ErsatzTV.Infrastructure/Search/ElasticSearchIndex.cs index 1cc47b58..e1f12f97 100644 --- a/ErsatzTV.Infrastructure/Search/ElasticSearchIndex.cs +++ b/ErsatzTV.Infrastructure/Search/ElasticSearchIndex.cs @@ -46,7 +46,7 @@ public class ElasticSearchIndex : ISearchIndex return exists.IsValidResponse; } - public int Version => 37; + public int Version => 38; public async Task Initialize( ILocalFileSystem localFileSystem, @@ -231,6 +231,7 @@ public class ElasticSearchIndex : ISearchIndex .Text(t => t.ShowTitle, t => t.Store(false)) .Text(t => t.ShowGenre, t => t.Store(false)) .Text(t => t.ShowTag, t => t.Store(false)) + .Text(t => t.ShowStudio, t => t.Store(false)) .Text(t => t.Style, t => t.Store(false)) .Text(t => t.Mood, t => t.Store(false)) .Text(t => t.Album, t => t.Store(false)) @@ -399,6 +400,7 @@ public class ElasticSearchIndex : ISearchIndex ShowTitle = showMetadata.Title, ShowGenre = showMetadata.Genres.Map(g => g.Name).ToList(), ShowTag = showMetadata.Tags.Map(t => t.Name).ToList(), + ShowStudio = showMetadata.Studios.Map(s => s.Name).ToList(), Language = await GetLanguages( searchRepository, await searchRepository.GetLanguagesForSeason(season)), @@ -587,6 +589,7 @@ public class ElasticSearchIndex : ISearchIndex doc.ShowTitle = showMetadata.Title; doc.ShowGenre = showMetadata.Genres.Map(g => g.Name).ToList(); doc.ShowTag = showMetadata.Tags.Map(t => t.Name).ToList(); + doc.ShowStudio = showMetadata.Studios.Map(s => s.Name).ToList(); } AddStatistics(doc, episode.MediaVersions); diff --git a/ErsatzTV.Infrastructure/Search/LuceneSearchIndex.cs b/ErsatzTV.Infrastructure/Search/LuceneSearchIndex.cs index d6dac8c9..98506393 100644 --- a/ErsatzTV.Infrastructure/Search/LuceneSearchIndex.cs +++ b/ErsatzTV.Infrastructure/Search/LuceneSearchIndex.cs @@ -60,6 +60,7 @@ public sealed class LuceneSearchIndex : ISearchIndex internal const string ShowTitleField = "show_title"; internal const string ShowGenreField = "show_genre"; internal const string ShowTagField = "show_tag"; + internal const string ShowStudioField = "show_studio"; internal const string MetadataKindField = "metadata_kind"; internal const string VideoCodecField = "video_codec"; internal const string VideoDynamicRange = "video_dynamic_range"; @@ -108,7 +109,7 @@ public sealed class LuceneSearchIndex : ISearchIndex return Task.FromResult(directoryExists && fileExists); } - public int Version => 37; + public int Version => 38; public async Task Initialize( ILocalFileSystem localFileSystem, @@ -681,6 +682,11 @@ public sealed class LuceneSearchIndex : ISearchIndex doc.Add(new TextField(ShowTagField, tag.Name, Field.Store.NO)); } + foreach (Studio studio in showMetadata.Studios) + { + doc.Add(new TextField(ShowStudioField, studio.Name, Field.Store.NO)); + } + List languages = await searchRepository.GetLanguagesForSeason(season); await AddLanguages(searchRepository, doc, languages); @@ -951,6 +957,11 @@ public sealed class LuceneSearchIndex : ISearchIndex { doc.Add(new TextField(ShowTagField, tag.Name, Field.Store.NO)); } + + foreach (Studio studio in showMetadata.Studios) + { + doc.Add(new TextField(ShowStudioField, studio.Name, Field.Store.NO)); + } } if (!string.IsNullOrWhiteSpace(metadata.Title)) diff --git a/ErsatzTV.Infrastructure/Search/Models/ElasticSearchItem.cs b/ErsatzTV.Infrastructure/Search/Models/ElasticSearchItem.cs index b084ef9e..66aaee13 100644 --- a/ErsatzTV.Infrastructure/Search/Models/ElasticSearchItem.cs +++ b/ErsatzTV.Infrastructure/Search/Models/ElasticSearchItem.cs @@ -109,6 +109,9 @@ public class ElasticSearchItem : MinimalElasticSearchItem [JsonPropertyName(LuceneSearchIndex.ShowTagField)] public List ShowTag { get; set; } + [JsonPropertyName(LuceneSearchIndex.ShowStudioField)] + public List ShowStudio { get; set; } + [JsonPropertyName(LuceneSearchIndex.StyleField)] public List Style { get; set; } diff --git a/ErsatzTV/Program.cs b/ErsatzTV/Program.cs index d1c2a7af..33040c5a 100644 --- a/ErsatzTV/Program.cs +++ b/ErsatzTV/Program.cs @@ -96,8 +96,7 @@ public class Program { loggerConfiguration = loggerConfiguration.WriteTo.Console( theme: AnsiConsoleTheme.Code, - formatProvider: CultureInfo.InvariantCulture, - outputTemplate: "[{Timestamp:HH:mm:ss} {Level:u3}] {Message:lj} <{SourceContext:l}> {NewLine}{Exception}"); + formatProvider: CultureInfo.InvariantCulture); // for troubleshooting log category // outputTemplate: "[{Timestamp:HH:mm:ss} {Level:u3}] {Message:lj} <{SourceContext:l}> {NewLine}{Exception}"