search movies and music videos by language (#148)

This commit is contained in:
Jason Dove
2021-04-06 07:42:21 -05:00
committed by GitHub
parent 3f406ac556
commit 0aac702853
2 changed files with 24 additions and 1 deletions
+20 -1
View File
@@ -40,6 +40,7 @@ namespace ErsatzTV.Infrastructure.Search
private const string JumpLetterField = "jump_letter";
private const string ReleaseDateField = "release_date";
private const string StudioField = "studio";
private const string LanguageField = "language";
private const string MovieType = "movie";
private const string ShowType = "show";
@@ -52,7 +53,7 @@ namespace ErsatzTV.Infrastructure.Search
public SearchIndex(ILogger<SearchIndex> logger) => _logger = logger;
public int Version => 2;
public int Version => 3;
public Task<bool> Initialize(ILocalFileSystem localFileSystem)
{
@@ -231,6 +232,8 @@ namespace ErsatzTV.Infrastructure.Search
new StringField(JumpLetterField, GetJumpLetter(metadata), Field.Store.YES)
};
AddLanguages(doc, movie.MediaVersions);
if (metadata.ReleaseDate.HasValue)
{
doc.Add(
@@ -270,6 +273,20 @@ namespace ErsatzTV.Infrastructure.Search
}
}
private void AddLanguages(Document doc, List<MediaVersion> mediaVersions)
{
Option<MediaVersion> maybeVersion = mediaVersions.HeadOrNone();
if (maybeVersion.IsSome)
{
MediaVersion version = maybeVersion.ValueUnsafe();
foreach (string lang in version.Streams.Map(ms => ms.Language).Distinct()
.Filter(s => !string.IsNullOrWhiteSpace(s)))
{
doc.Add(new StringField(LanguageField, lang, Field.Store.NO));
}
}
}
private void UpdateShow(Show show)
{
Option<ShowMetadata> maybeMetadata = show.ShowMetadata.HeadOrNone();
@@ -350,6 +367,8 @@ namespace ErsatzTV.Infrastructure.Search
new StringField(JumpLetterField, GetJumpLetter(metadata), Field.Store.YES)
};
AddLanguages(doc, musicVideo.MediaVersions);
if (metadata.ReleaseDate.HasValue)
{
doc.Add(