title: MongoDB - PHP and Full text search
body: <p>I wrote this command:</p>
  
  <pre><code>    db.collection.find(
          { $text: {$search: "foo query string"}}, 
          { score: {$meta  : "textScore"} } 
      ).sort({ score:{$meta: "textScore"}})
  </code></pre>
  
  <p>It works fine in <code>mongo shell</code>, but I want convert this into <code>php</code>. Then I wrote different but the same php query:</p>
  
  <pre><code>    $store = $db-&gt;collection-&gt;find([
          ['$text' =&gt; 'foo query string'],
          ['score' =&gt; ['$meta' =&gt; 'textScore']]
      ])-&gt;sort(['score' =&gt; ['$meta' =&gt; 'textScore']]);
  </code></pre>
  
  <p>In this case I get an error:</p>
  
  <pre><code>127.0.0.1:27017: Can't canonicalize query: BadValue must have
                   $meta projection for all $meta sort keys
  </code></pre>
  
  <p>Obviously <code>Index</code> is created.
  I have no idea what is wrong. Can you help me? Thank you in advance.</p>