fix(mysql): change mysql against mode (close #2903 close #2844 pr #2904)

This commit is contained in:
AkashiCoin 2023-01-05 17:11:58 +08:00 committed by GitHub
parent 428e59a844
commit 14d4ddb752
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -65,7 +65,7 @@ func SearchNode(req model.SearchReq) ([]model.SearchNode, int64, error) {
searchDB = db.Model(&model.SearchNode{}).Where(whereInParent(req.Parent)).Where(keywordsClause)
case "mysql":
searchDB = db.Model(&model.SearchNode{}).Where(whereInParent(req.Parent)).
Where("MATCH (name) AGAINST (? IN NATURAL LANGUAGE MODE)", req.Keywords)
Where("MATCH (name) AGAINST (? IN BOOLEAN MODE)", "'*" + req.Keywords + "*'")
case "postgres":
searchDB = db.Model(&model.SearchNode{}).Where(whereInParent(req.Parent)).
Where("to_tsvector(name) @@ to_tsquery(?)", strings.Join(strings.Fields(req.Keywords), " & "))