title: Mongodb aggregation failure: "FieldPath field names may not start with '$'."
body: <p>I'm trying to figure out why this code fails:</p>
  <pre><code>db.restaurants.drop();
  
  db.restaurants.insertMany( [
    { &quot;_id&quot; : 1, &quot;borough&quot; : &quot;Manhattan&quot;},
  ] );
  
  db.restaurants.createIndex({
    &quot;borough&quot;: &quot;text&quot;
  })
  
  db.restaurants.aggregate([
    { $match: { $text: { $search: &quot;a&quot; } } },
    { $sort: {score: {&quot;$meta&quot;: &quot;textScore&quot;}}},
    { $project: {&quot;_id&quot;: true}},
  ])
  </code></pre>
  <p>Error output:</p>
  <pre><code>uncaught exception: Error: command failed: {
          &quot;ok&quot; : 0,
          &quot;errmsg&quot; : &quot;FieldPath field names may not start with '$'.&quot;,
          &quot;code&quot; : 16410,
          &quot;codeName&quot; : &quot;Location16410&quot;
  } : aggregate failed :
  _getErrorWithCode@src/mongo/shell/utils.js:25:13
  doassert@src/mongo/shell/assert.js:18:14
  _assertCommandWorked@src/mongo/shell/assert.js:639:17
  assert.commandWorked@src/mongo/shell/assert.js:729:16
  DB.prototype._runAggregate@src/mongo/shell/db.js:266:5
  DBCollection.prototype.aggregate@src/mongo/shell/collection.js:1058:12
  @(shell):1:1
  </code></pre>
  <p>I know it has something to do with the project statement...</p>
  <p>Thank you in advance!</p>
  <p>-daniel</p>