[backend/core] Fix negated search parameters when match:words is used

This commit is contained in:
Laura Hausmann 2025-01-10 07:04:57 +01:00
parent af750a010d
commit 37fc124b08
No known key found for this signature in database
GPG key ID: D044E84C5BE01605

View file

@ -274,34 +274,34 @@ public static class QueryableFtsExtensions
) => matchType.Equals(MatchFilterType.Substring) ) => matchType.Equals(MatchFilterType.Substring)
? caseSensitivity.Equals(CaseFilterType.Sensitive) ? caseSensitivity.Equals(CaseFilterType.Sensitive)
? negated ? negated
? !EF.Functions.Like(note.Text!, "%" + query + "%", @"\") ? !EF.Functions.Like(note.Text ?? "", "%" + query + "%", @"\")
&& !EF.Functions.Like(note.Cw!, "%" + query + "%", @"\") && !EF.Functions.Like(note.Cw ?? "", "%" + query + "%", @"\")
&& !EF.Functions.Like(note.CombinedAltText!, "%" + query + "%", @"\") && !EF.Functions.Like(note.CombinedAltText ?? "", "%" + query + "%", @"\")
: EF.Functions.Like(note.Text!, "%" + query + "%", @"\") : EF.Functions.Like(note.Text ?? "", "%" + query + "%", @"\")
|| EF.Functions.Like(note.Cw!, "%" + query + "%", @"\") || EF.Functions.Like(note.Cw ?? "", "%" + query + "%", @"\")
|| EF.Functions.Like(note.CombinedAltText!, "%" + query + "%", @"\") || EF.Functions.Like(note.CombinedAltText ?? "", "%" + query + "%", @"\")
: negated : negated
? !EF.Functions.ILike(note.Text!, "%" + query + "%", @"\") ? !EF.Functions.ILike(note.Text ?? "", "%" + query + "%", @"\")
&& !EF.Functions.ILike(note.Cw!, "%" + query + "%", @"\") && !EF.Functions.ILike(note.Cw ?? "", "%" + query + "%", @"\")
&& !EF.Functions.ILike(note.CombinedAltText!, "%" + query + "%", @"\") && !EF.Functions.ILike(note.CombinedAltText ?? "", "%" + query + "%", @"\")
: EF.Functions.ILike(note.Text!, "%" + query + "%", @"\") : EF.Functions.ILike(note.Text ?? "", "%" + query + "%", @"\")
|| EF.Functions.ILike(note.Cw!, "%" + query + "%", @"\") || EF.Functions.ILike(note.Cw ?? "", "%" + query + "%", @"\")
|| EF.Functions.ILike(note.CombinedAltText!, "%" + query + "%", @"\") || EF.Functions.ILike(note.CombinedAltText ?? "", "%" + query + "%", @"\")
: caseSensitivity.Equals(CaseFilterType.Sensitive) : caseSensitivity.Equals(CaseFilterType.Sensitive)
? negated ? negated
? !Regex.IsMatch(note.Text!, "\\y" + query + "\\y") ? !Regex.IsMatch(note.Text ?? "", "\\y" + query + "\\y")
&& !Regex.IsMatch(note.Cw!, "\\y" + query + "\\y") && !Regex.IsMatch(note.Cw ?? "", "\\y" + query + "\\y")
&& !Regex.IsMatch(note.CombinedAltText!, "\\y" + query + "\\y") && !Regex.IsMatch(note.CombinedAltText ?? "", "\\y" + query + "\\y")
: Regex.IsMatch(note.Text!, "\\y" + query + "\\y") : Regex.IsMatch(note.Text ?? "", "\\y" + query + "\\y")
|| Regex.IsMatch(note.Cw!, "\\y" + query + "\\y") || Regex.IsMatch(note.Cw ?? "", "\\y" + query + "\\y")
|| Regex.IsMatch(note.CombinedAltText!, "\\y" + query + "\\y") || Regex.IsMatch(note.CombinedAltText ?? "", "\\y" + query + "\\y")
: negated : negated
? !Regex.IsMatch(note.Text!, "\\y" + query + "\\y", RegexOptions.IgnoreCase) ? !Regex.IsMatch(note.Text ?? "", "\\y" + query + "\\y", RegexOptions.IgnoreCase)
&& !Regex.IsMatch(note.Cw!, "\\y" + query + "\\y", RegexOptions.IgnoreCase) && !Regex.IsMatch(note.Cw ?? "", "\\y" + query + "\\y", RegexOptions.IgnoreCase)
&& !Regex.IsMatch(note.CombinedAltText!, "\\y" + query + "\\y", RegexOptions.IgnoreCase) && !Regex.IsMatch(note.CombinedAltText ?? "", "\\y" + query + "\\y", RegexOptions.IgnoreCase)
: Regex.IsMatch(note.Text!, "\\y" + query + "\\y", RegexOptions.IgnoreCase) : Regex.IsMatch(note.Text ?? "", "\\y" + query + "\\y", RegexOptions.IgnoreCase)
|| Regex.IsMatch(note.Cw!, "\\y" + query + "\\y", RegexOptions.IgnoreCase) || Regex.IsMatch(note.Cw ?? "", "\\y" + query + "\\y", RegexOptions.IgnoreCase)
|| Regex.IsMatch(note.CombinedAltText!, "\\y" + query + "\\y", RegexOptions.IgnoreCase); || Regex.IsMatch(note.CombinedAltText ?? "", "\\y" + query + "\\y", RegexOptions.IgnoreCase);
[Projectable] [Projectable]
[SuppressMessage("ReSharper", "MemberCanBePrivate.Global", [SuppressMessage("ReSharper", "MemberCanBePrivate.Global",