From c47099895e0a8dae77ed48a49bba4e37f12feb17 Mon Sep 17 00:00:00 2001 From: Jason Dove Date: Sun, 26 Jun 2022 13:34:54 -0500 Subject: [PATCH] include item state in search index duplicate filter (#875) --- CHANGELOG.md | 1 + ErsatzTV.Infrastructure/Search/SearchIndex.cs | 14 ++++++++++---- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 687586f06..40e0c0b71 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). - Properly apply changes to episode title, sort title, outline and plot from Plex - Fix search index for other videos and songs - In previous versions, some libraries would incorrectly display only one item +- Properly display old versions of renamed items in trash ## [0.6.2-beta] - 2022-06-18 ### Fixed diff --git a/ErsatzTV.Infrastructure/Search/SearchIndex.cs b/ErsatzTV.Infrastructure/Search/SearchIndex.cs index 8cc13a7ba..578b01301 100644 --- a/ErsatzTV.Infrastructure/Search/SearchIndex.cs +++ b/ErsatzTV.Infrastructure/Search/SearchIndex.cs @@ -88,7 +88,7 @@ public sealed class SearchIndex : ISearchIndex _initialized = false; } - public int Version => 26; + public int Version => 27; public async Task Initialize( ILocalFileSystem localFileSystem, @@ -1111,14 +1111,20 @@ public sealed class SearchIndex : ISearchIndex return query; } + // this is used for filtering duplicate search results private static string GetTitleAndYear(Metadata metadata) => metadata switch { EpisodeMetadata em => - $"{em.Title}_{em.Year}_{em.Episode.Season.SeasonNumber}_{em.EpisodeNumber}" + $"{em.Title}_{em.Year}_{em.Episode.Season.SeasonNumber}_{em.EpisodeNumber}_{em.Episode.State}" .ToLowerInvariant(), - OtherVideoMetadata ovm => $"{ovm.Title}_{ovm.Year}".ToLowerInvariant(), - SongMetadata sm => $"{sm.Title}_{sm.Year}".ToLowerInvariant(), + OtherVideoMetadata ovm => $"{ovm.Title}_{ovm.Year}_{ovm.OtherVideo.State}".ToLowerInvariant(), + SongMetadata sm => $"{sm.Title}_{sm.Year}_{sm.Song.State}".ToLowerInvariant(), + MovieMetadata mm => $"{mm.Title}_{mm.Year}_{mm.Movie.State}".ToLowerInvariant(), + ArtistMetadata am => $"{am.Title}_{am.Year}_{am.Artist.State}".ToLowerInvariant(), + MusicVideoMetadata mvm => $"{mvm.Title}_{mvm.Year}_{mvm.MusicVideo.State}".ToLowerInvariant(), + SeasonMetadata sm => $"{sm.Title}_{sm.Year}_{sm.Season.State}".ToLowerInvariant(), + ShowMetadata sm => $"{sm.Title}_{sm.Year}_{sm.Show.State}".ToLowerInvariant(), _ => $"{metadata.Title}_{metadata.Year}".ToLowerInvariant() };