Index Bounds on Mongo Regex Search : <p>I'm using MongoDB, and I have a collection of documents with the following structure:</p>

<pre><code>{
    fName:"Foo",
    lName:"Barius",
    email:"fbarius@example.com",
    search:"foo barius"
}
</code></pre>

<p>I am building a function that will perform a regular expression search on the <code>search</code> field. To optimize performance, I have indexed this collection on the search field. However, things are still a bit slow. So I ran an <code>explain()</code> on a sample query:</p>

<pre><code>db.Collection.find({search:/bar/}).explain();
</code></pre>

<p>Looking under the winning plan, I see the following index bounds used:</p>

<pre><code>"search": [
        "[\"\", {})",
        "[/.*bar.*/, /.*bar.*/]"
]
</code></pre>

<p>The second set makes sense - it's looking from anything that contains bar to anything that contains bar. However, the first set baffles me. It appears to be looking in the bounds of <code>""</code> inclusive to <code>{}</code> exclusive. I'm concerned that this extra set of bounds is slowing down my query. Is it necessary to keep? If it's not, how can I prevent it from being included?</p>
