因为我们不知道用户是否只会传递名字或姓氏的名字search := "Carlos M"s := strings.Split(search, " ")s := append(s, "") // incase name is only supplied then empty string will be used for surnamequery := bson.M{ "nombre": bson.M{"$regex": `(?i)` + s[0]}, "apellido": bson.M{"$regex": `(?i)` + s[1]},}