我想在 mongodb 的许多领域进行搜索。
这是我到目前为止所做的
var filter bson.D
filter = append(filter, bson.E{"title", primitive.Regex{Pattern: "input", Options: "i"}})
filter = append(filter, bson.E{"author", primitive.Regex{Pattern: "input", Options: "i"}})
filter = append(filter, bson.E{"content", primitive.Regex{Pattern: "input", Options: "i"}})
cur, err := p.postProposalCollection.Find(ctx, filter)
但是它是AND这样工作的
WHERE title ~ 'input' AND author ~ 'input' AND content ~ 'input'
我希望它像这样工作
WHERE title ~ 'input' OR author ~ 'input' OR content ~ 'input'
UYOU
相关分类