title: How to write mongodb search in golang using mgo
body: <p>Here is my JSON file:</p>
  
  <pre><code>[{
      "name": "chetan",
      "age": 23,
      "hobby": ["cricket", "football"]
  }, {
      "name": "raj",
      "age": 24,
      "hobby": ["cricket", "golf"]
  }]
  </code></pre>
  
  <p>Here is the golang code I tried but didn't work as expected.</p>
  
  <pre><code>id:= "ket"
  c.EnsureIndexKey("hobby")
  err = c.Find(bson.M{"$hobby": bson.M{"$search": id,},}).All(&amp;result)
  </code></pre>
  
  <p>It gives error:</p>
  
  <blockquote>
    <p>$hobby exit status 1</p>
  </blockquote>