Browse Source

add show_studio search field (#1584)

pull/1585/head
Jason Dove 3 years ago committed by GitHub
parent
commit
7d5cd229d4
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 1
      CHANGELOG.md
  2. 14
      ErsatzTV.Infrastructure/Data/Repositories/SearchRepository.cs
  3. 5
      ErsatzTV.Infrastructure/Search/ElasticSearchIndex.cs
  4. 13
      ErsatzTV.Infrastructure/Search/LuceneSearchIndex.cs
  5. 3
      ErsatzTV.Infrastructure/Search/Models/ElasticSearchItem.cs
  6. 3
      ErsatzTV/Program.cs

1
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/). The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
## [Unreleased] ## [Unreleased]
- Add `show_studio` to search index for seasons and episodes
## [0.8.5-beta] - 2024-01-30 ## [0.8.5-beta] - 2024-01-30
### Added ### Added

14
ErsatzTV.Infrastructure/Data/Repositories/SearchRepository.cs

@ -61,6 +61,10 @@ public class SearchRepository : ISearchRepository
.ThenInclude(s => s.Show) .ThenInclude(s => s.Show)
.ThenInclude(s => s.ShowMetadata) .ThenInclude(s => s.ShowMetadata)
.ThenInclude(s => s.Tags) .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) .Include(mi => (mi as Season).SeasonMetadata)
.ThenInclude(sm => sm.Genres) .ThenInclude(sm => sm.Genres)
.Include(mi => (mi as Season).SeasonMetadata) .Include(mi => (mi as Season).SeasonMetadata)
@ -77,6 +81,9 @@ public class SearchRepository : ISearchRepository
.Include(mi => (mi as Season).Show) .Include(mi => (mi as Season).Show)
.ThenInclude(sm => sm.ShowMetadata) .ThenInclude(sm => sm.ShowMetadata)
.ThenInclude(sm => sm.Tags) .ThenInclude(sm => sm.Tags)
.Include(mi => (mi as Season).Show)
.ThenInclude(sm => sm.ShowMetadata)
.ThenInclude(sm => sm.Studios)
.Include(mi => (mi as Show).ShowMetadata) .Include(mi => (mi as Show).ShowMetadata)
.ThenInclude(mm => mm.Genres) .ThenInclude(mm => mm.Genres)
.Include(mi => (mi as Show).ShowMetadata) .Include(mi => (mi as Show).ShowMetadata)
@ -231,6 +238,10 @@ public class SearchRepository : ISearchRepository
.ThenInclude(s => s.Show) .ThenInclude(s => s.Show)
.ThenInclude(s => s.ShowMetadata) .ThenInclude(s => s.ShowMetadata)
.ThenInclude(s => s.Tags) .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) .Include(mi => (mi as Season).SeasonMetadata)
.ThenInclude(sm => sm.Genres) .ThenInclude(sm => sm.Genres)
.Include(mi => (mi as Season).SeasonMetadata) .Include(mi => (mi as Season).SeasonMetadata)
@ -247,6 +258,9 @@ public class SearchRepository : ISearchRepository
.Include(mi => (mi as Season).Show) .Include(mi => (mi as Season).Show)
.ThenInclude(sm => sm.ShowMetadata) .ThenInclude(sm => sm.ShowMetadata)
.ThenInclude(sm => sm.Tags) .ThenInclude(sm => sm.Tags)
.Include(mi => (mi as Season).Show)
.ThenInclude(sm => sm.ShowMetadata)
.ThenInclude(sm => sm.Studios)
.Include(mi => (mi as Show).ShowMetadata) .Include(mi => (mi as Show).ShowMetadata)
.ThenInclude(mm => mm.Genres) .ThenInclude(mm => mm.Genres)
.Include(mi => (mi as Show).ShowMetadata) .Include(mi => (mi as Show).ShowMetadata)

5
ErsatzTV.Infrastructure/Search/ElasticSearchIndex.cs

@ -46,7 +46,7 @@ public class ElasticSearchIndex : ISearchIndex
return exists.IsValidResponse; return exists.IsValidResponse;
} }
public int Version => 37; public int Version => 38;
public async Task<bool> Initialize( public async Task<bool> Initialize(
ILocalFileSystem localFileSystem, ILocalFileSystem localFileSystem,
@ -231,6 +231,7 @@ public class ElasticSearchIndex : ISearchIndex
.Text(t => t.ShowTitle, t => t.Store(false)) .Text(t => t.ShowTitle, t => t.Store(false))
.Text(t => t.ShowGenre, t => t.Store(false)) .Text(t => t.ShowGenre, t => t.Store(false))
.Text(t => t.ShowTag, 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.Style, t => t.Store(false))
.Text(t => t.Mood, t => t.Store(false)) .Text(t => t.Mood, t => t.Store(false))
.Text(t => t.Album, t => t.Store(false)) .Text(t => t.Album, t => t.Store(false))
@ -399,6 +400,7 @@ public class ElasticSearchIndex : ISearchIndex
ShowTitle = showMetadata.Title, ShowTitle = showMetadata.Title,
ShowGenre = showMetadata.Genres.Map(g => g.Name).ToList(), ShowGenre = showMetadata.Genres.Map(g => g.Name).ToList(),
ShowTag = showMetadata.Tags.Map(t => t.Name).ToList(), ShowTag = showMetadata.Tags.Map(t => t.Name).ToList(),
ShowStudio = showMetadata.Studios.Map(s => s.Name).ToList(),
Language = await GetLanguages( Language = await GetLanguages(
searchRepository, searchRepository,
await searchRepository.GetLanguagesForSeason(season)), await searchRepository.GetLanguagesForSeason(season)),
@ -587,6 +589,7 @@ public class ElasticSearchIndex : ISearchIndex
doc.ShowTitle = showMetadata.Title; doc.ShowTitle = showMetadata.Title;
doc.ShowGenre = showMetadata.Genres.Map(g => g.Name).ToList(); doc.ShowGenre = showMetadata.Genres.Map(g => g.Name).ToList();
doc.ShowTag = showMetadata.Tags.Map(t => t.Name).ToList(); doc.ShowTag = showMetadata.Tags.Map(t => t.Name).ToList();
doc.ShowStudio = showMetadata.Studios.Map(s => s.Name).ToList();
} }
AddStatistics(doc, episode.MediaVersions); AddStatistics(doc, episode.MediaVersions);

13
ErsatzTV.Infrastructure/Search/LuceneSearchIndex.cs

@ -60,6 +60,7 @@ public sealed class LuceneSearchIndex : ISearchIndex
internal const string ShowTitleField = "show_title"; internal const string ShowTitleField = "show_title";
internal const string ShowGenreField = "show_genre"; internal const string ShowGenreField = "show_genre";
internal const string ShowTagField = "show_tag"; internal const string ShowTagField = "show_tag";
internal const string ShowStudioField = "show_studio";
internal const string MetadataKindField = "metadata_kind"; internal const string MetadataKindField = "metadata_kind";
internal const string VideoCodecField = "video_codec"; internal const string VideoCodecField = "video_codec";
internal const string VideoDynamicRange = "video_dynamic_range"; internal const string VideoDynamicRange = "video_dynamic_range";
@ -108,7 +109,7 @@ public sealed class LuceneSearchIndex : ISearchIndex
return Task.FromResult(directoryExists && fileExists); return Task.FromResult(directoryExists && fileExists);
} }
public int Version => 37; public int Version => 38;
public async Task<bool> Initialize( public async Task<bool> Initialize(
ILocalFileSystem localFileSystem, ILocalFileSystem localFileSystem,
@ -681,6 +682,11 @@ public sealed class LuceneSearchIndex : ISearchIndex
doc.Add(new TextField(ShowTagField, tag.Name, Field.Store.NO)); 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<string> languages = await searchRepository.GetLanguagesForSeason(season); List<string> languages = await searchRepository.GetLanguagesForSeason(season);
await AddLanguages(searchRepository, doc, languages); await AddLanguages(searchRepository, doc, languages);
@ -951,6 +957,11 @@ public sealed class LuceneSearchIndex : ISearchIndex
{ {
doc.Add(new TextField(ShowTagField, tag.Name, Field.Store.NO)); 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)) if (!string.IsNullOrWhiteSpace(metadata.Title))

3
ErsatzTV.Infrastructure/Search/Models/ElasticSearchItem.cs

@ -109,6 +109,9 @@ public class ElasticSearchItem : MinimalElasticSearchItem
[JsonPropertyName(LuceneSearchIndex.ShowTagField)] [JsonPropertyName(LuceneSearchIndex.ShowTagField)]
public List<string> ShowTag { get; set; } public List<string> ShowTag { get; set; }
[JsonPropertyName(LuceneSearchIndex.ShowStudioField)]
public List<string> ShowStudio { get; set; }
[JsonPropertyName(LuceneSearchIndex.StyleField)] [JsonPropertyName(LuceneSearchIndex.StyleField)]
public List<string> Style { get; set; } public List<string> Style { get; set; }

3
ErsatzTV/Program.cs

@ -96,8 +96,7 @@ public class Program
{ {
loggerConfiguration = loggerConfiguration.WriteTo.Console( loggerConfiguration = loggerConfiguration.WriteTo.Console(
theme: AnsiConsoleTheme.Code, theme: AnsiConsoleTheme.Code,
formatProvider: CultureInfo.InvariantCulture, formatProvider: CultureInfo.InvariantCulture);
outputTemplate: "[{Timestamp:HH:mm:ss} {Level:u3}] {Message:lj} <{SourceContext:l}> {NewLine}{Exception}");
// for troubleshooting log category // for troubleshooting log category
// outputTemplate: "[{Timestamp:HH:mm:ss} {Level:u3}] {Message:lj} <{SourceContext:l}> {NewLine}{Exception}" // outputTemplate: "[{Timestamp:HH:mm:ss} {Level:u3}] {Message:lj} <{SourceContext:l}> {NewLine}{Exception}"

Loading…
Cancel
Save