title: Change type of field inside mongoDB aggregation and does $lookup utilises index on fields or not?
body: <p>I am performing joins in mongodb using $lookup, now i am facing a problem here.
  I have two collections first one to contains users all bookmarks brands and the second one contains all details about the brands.Now i am trying to return all brands details bookmarked by the user.</p>
  
  <p><strong>user_bookmarked</strong> Collection</p>
  
  <pre><code>{"mobile_no": "8971740148", "brands": ["5829c1df334d40e20e1d1c19", "5829c1df334d40e20e1d1c20", "5829c1df334d40e20e1d1c21"]}
  </code></pre>
  
  <p><strong>brands</strong> Collection</p>
  
  <pre><code>{"_id": ObjectId("5829c1df334d40e20e1d1c19"), "brand_name": "Versace"}
  {"_id": ObjectId("5829c1df334d40e20e1d1c20"), "brand_name": "Lee Cooper"}
  {"_id": ObjectId("5829c1df334d40e20e1d1c21"), "brand_name": "Levis"}
  </code></pre>
  
  <p>My aggregation pipeline code is given below</p>
  
  <pre><code>                { $match: { mobile_no: mobile_no }},
                  { $unwind: { path: "$brands", includeArrayIndex: "brandsposition"}},
                  { $lookup: {from: "brands",localField: "brands",foreignField: "_id",as: "user_bookmarks"}},
  </code></pre>
  
  <p>Now the problem i am facing is that above code doesn't return anything as i am storing brands ids as string in my user_bookmarked collection but not as ObjectId so nothing is being returned. Now can anyone please tell me how can i change field type inside aggregation query.</p>
  
  <p>Second thing i want to ask please tell me when using $lookup then does mongodb utilises index on foreign_field or not. Because i ran above aggregation pipeline with <strong>explain: true</strong> but i don't found any index that was utilised by above query i got this returned by the output.</p>
  
  <pre><code>db.user_bookmarked.runCommand('aggregate', {pipeline: [{ $match: { mobile_no: mobile_no }},
              { $unwind: { path: "$brands", includeArrayIndex: "brandsposition"}},
              { $lookup: {from: "brands",localField: "brands",foreignField: "_id",as: "user_bookmarks"}}], explain: true})
  {
          "waitedMS" : NumberLong(0),
          "stages" : [
                  {
                          "$cursor" : {
                                  "query" : {
                                          "mobile_no" : "8971740148"
                                  },
                                  "queryPlanner" : {
                                          "plannerVersion" : 1,
                                          "namespace" : "test.restaurants",
                                          "indexFilterSet" : false,
                                          "parsedQuery" : {
                                                  "mobile_no" : {
                                                          "$eq" : "8971740148"
                                                  }
                                          },
                                          "winningPlan" : {
                                                  "stage" : "COLLSCAN",
                                                  "filter" : {
                                                          "mobile_no" : {
                                                                  "$eq" : "8971740148"
                                                          }
                                                  },
                                                  "direction" : "forward"
                                          },
                                          "rejectedPlans" : [ ]
                                  }
                          }
                  },
                  {
                          "$unwind" : {
                                  "path" : "$brands",
                                  "includeArrayIndex" : "brandsposition"
                          }
                  },
                  {
                          "$lookup" : {
                                  "from" : "brands",
                                  "as" : "user_bookmarks",
                                  "localField" : "brands",
                                  "foreignField" : "_id"
                          }
                  }
          ],
          "ok" : 1
  }
  </code></pre>
  
  <p>Now can anyone please help me out of here i have searched about both of this thing which is how to change type of field inside aggregation and does $lookup utilises indexes but Haven't found anything useful please help me out of here guys it would be really appreciable.</p>