如何在mgo中进行文本搜索?

I'm trying to search "efg" in field named "abc"

c.Find(bson.M{"$text": bson.M{"abc": "efg"}})

c is Collection object. I'm not getting any result. What am I doing wrong?

You are generating {$text:{abc:"efg"}}, but your query should look like this: {$text:{$search:"efg"}}

So try updating your code to:

c.EnsureIndexKey("abc")
c.Find(bson.M{"$text": bson.M{"$search": "efg"}})

Keep in mind that to search with $text, you need to specify an index. Check out this document that explains how to use it: http://docs.mongodb.org/manual/reference/operator/query/text/

use $regex(option i for case insensitive)
example:

c.Find(bson.M{"abc": &bson.RegEx{Pattern: "efg", Options: "i"}})