Merge pull request #8914 from bradbeattie/augmented-tag-searching

Augment tag searching to consider individual ItemValues instead of the delimited tags field
This commit is contained in:
Claus Vium 2023-07-03 08:51:46 +02:00 committed by GitHub
commit 10fde0a2c1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -2452,7 +2452,9 @@ namespace Emby.Server.Implementations.Data
if (query.SearchTerm.Length > 1)
{
builder.Append("+ ((CleanName like @SearchTermContains or (OriginalTitle not null and OriginalTitle like @SearchTermContains)) * 10)");
builder.Append("+ ((Tags not null and Tags like @SearchTermContains) * 5)");
builder.Append("+ (SELECT COUNT(1) * 1 from ItemValues where ItemId=Guid and CleanValue like @SearchTermContains)");
builder.Append("+ (SELECT COUNT(1) * 2 from ItemValues where ItemId=Guid and CleanValue like @SearchTermStartsWith)");
builder.Append("+ (SELECT COUNT(1) * 10 from ItemValues where ItemId=Guid and CleanValue like @SearchTermEquals)");
}
builder.Append(") as SearchScore");
@ -2483,6 +2485,11 @@ namespace Emby.Server.Implementations.Data
{
statement.TryBind("@SearchTermContains", "%" + searchTerm + "%");
}
if (commandText.Contains("@SearchTermEquals", StringComparison.OrdinalIgnoreCase))
{
statement.TryBind("@SearchTermEquals", searchTerm);
}
}
private void BindSimilarParams(InternalItemsQuery query, IStatement statement)