aboutsummaryrefslogtreecommitdiff
path: root/Emby.Server.Implementations/Library/Search/SqlSearchProvider.cs
diff options
context:
space:
mode:
authorShadowghost <Shadowghost@users.noreply.github.com>2026-09-15 11:13:48 -0400
committerCody Robibero <cody@robibe.ro>2026-09-15 11:13:48 -0400
commit8150ee2484dabed61718ef43d5c98cdd2c0fa01c (patch)
treecb81b848e8931122d4771de780746be51a0e1d94 /Emby.Server.Implementations/Library/Search/SqlSearchProvider.cs
parent7baca5f2b891cbc92e48145e633e1417d9bf2de3 (diff)
Backport pull request #17842 from jellyfin/release-12.z
Fix versions of a video still listing separately from their group and preserve manual merges Original-merge: cabec7ec28df671e3bb1c360c32db60b085f4084 Merged-by: crobibero <cody@robibe.ro> Backported-by: Cody Robibero <cody@robibe.ro>
Diffstat (limited to 'Emby.Server.Implementations/Library/Search/SqlSearchProvider.cs')
-rw-r--r--Emby.Server.Implementations/Library/Search/SqlSearchProvider.cs7
1 files changed, 7 insertions, 0 deletions
diff --git a/Emby.Server.Implementations/Library/Search/SqlSearchProvider.cs b/Emby.Server.Implementations/Library/Search/SqlSearchProvider.cs
index c4d3b249d5..2cbfb6a4fa 100644
--- a/Emby.Server.Implementations/Library/Search/SqlSearchProvider.cs
+++ b/Emby.Server.Implementations/Library/Search/SqlSearchProvider.cs
@@ -115,6 +115,7 @@ public class SqlSearchProvider : IInternalSearchProvider
dbQuery = ApplyMediaTypeFilter(dbQuery, query.MediaTypes);
dbQuery = ApplyParentFilter(dbQuery, query.ParentId);
dbQuery = ApplyUserAccessFilter(dbContext, dbQuery, query);
+ dbQuery = ExcludeVersionsOfMatchedPrimaries(dbQuery);
// Compute the score in SQL: the ternary translates to a CASE WHEN. CleanName is
// the pre-normalized (lowercase, diacritic-stripped) form, so we score against it
@@ -193,6 +194,12 @@ public class SqlSearchProvider : IInternalSearchProvider
return query.Where(e => e.ParentId == pid || e.Parents!.Any(p => p.ParentItemId == pid));
}
+ private static IQueryable<BaseItemEntity> ExcludeVersionsOfMatchedPrimaries(IQueryable<BaseItemEntity> query)
+ {
+ var matched = query;
+ return query.Where(e => e.PrimaryVersionId == null || !matched.Any(p => p.Id == e.PrimaryVersionId));
+ }
+
private IQueryable<BaseItemEntity> ApplyUserAccessFilter(
JellyfinDbContext dbContext,
IQueryable<BaseItemEntity> query,