title: Mongoose - How to search for a partial string match and then sort the results by score?
body: <p>I'm creating a back-end for a web app using Node, Express, Mongoose, and Mongodb.  I'm trying to run a partial search on some user profiles with a name field and an array of tags so that "re" will return profiles with a tag array or name that contains "red" and "blueish" will return profiles with a tag array or name that contains "blue"</p>
  
  <p>I found the syntax to add regex expressions.  Something along the lines of:</p>
  
  <pre><code>    Profile.find(.0
          { "tags": { "$regex": "re", "$options": "i" } },
          function(err,docs) { 
              str = JSON.stringify(docs, null, 4); 
              console.log(str)
          } 
      );
  </code></pre>
  
  <p>I'm also trying to score them and sort the results.  I found another stack overflow post that is along the lines of:</p>
  
  <pre><code>Profile.find({ "$text": { "$search": input } })
      .select({ "score": { "$meta": "textScore" } })
      .sort({ "score": { "$meta": "textScore" } })
      .exec(function(err,result) {
  str = JSON.stringify(result, null, 4); 
  console.log(str)
      }
  );
  </code></pre>
  
  <p>But after reading the docs, I'm still a but fuzzy on how to combine the two concepts.  Any tips?  </p>