title: how to structure a compound index in mongodb
body: <p>I need some advice in creating and ordering indexes in mongo.</p>
  
  <p>I have a post collection with 5 properties:</p>
  
  <p>Posts</p>
  
  <ul>
  <li>status </li>
  <li>start date  </li>
  <li>end date </li>
  <li>lowerCaseTitle </li>
  <li>sortOrder</li>
  </ul>
  
  <p>Almost all the posts will have the same status of 1 and only a handful will have a rejected status.  All my queries will filter on status, start and end dates, and sort on sortOrder.   I also will have one query that does a regex search on the title.</p>
  
  <p>Should I set up a compound key on {status:1, start:1, end:1, sort:1}?  Does it matter which order I put the fields in the compound index - should I put status first in the compound index since it's the most broad?  Is it better to do a compound index rather than a single index on each property?  Does mongo only use a single index on any given query?</p>
  
  <p>Are there any hints for indexes on lowerCaseTitle if I'm doing a regex query on that?</p>
  
  <p>sample queries are:</p>
  
  <pre><code>db.posts.find({status: {$gte:0}, start: {$lt: today}, end: {$gt: today}}).sort({sortOrder:1})
  
  db.posts.find( {lowerCaseTitle: /japan/, status:{$gte:0}, start: {$lt: today}, end: {$gt: today}}).sort({sortOrder:1})
  </code></pre>