From 89b495577eaa5de83e39456be096a6827ebcae4e Mon Sep 17 00:00:00 2001 From: LittleSheep Date: Wed, 16 Oct 2024 21:01:17 +0800 Subject: [PATCH] :necktie: Update search post include range --- pkg/internal/services/posts.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/pkg/internal/services/posts.go b/pkg/internal/services/posts.go index 36f1ef0..9d7c45d 100644 --- a/pkg/internal/services/posts.go +++ b/pkg/internal/services/posts.go @@ -99,7 +99,10 @@ func FilterPostDraft(tx *gorm.DB) *gorm.DB { func FilterPostWithFuzzySearch(tx *gorm.DB, probe string) *gorm.DB { probe = "%" + probe + "%" - return tx.Where("? AND body->>'content' ILIKE ?", gorm.Expr("body ? 'content'"), probe) + return tx. + Where("? AND body->>'content' ILIKE ?", gorm.Expr("body ? 'content'"), probe). + Or("? AND body->>'title' ILIKE ?", gorm.Expr("body ? 'title'"), probe). + Or("? AND body->>'description' ILIKE ?", gorm.Expr("body ? 'description'"), probe) } func PreloadGeneral(tx *gorm.DB) *gorm.DB {