title: Spring Data MongoDB Indexed(unique=true)
body: <p>I'm having a lot of problems with <code>Spring Data</code> and <code>MongoDB</code> when it comes to an Indexed field.  </p>
  
  <p>I've gone over the docs, but they aren't very good at explaining the difference between <code>@Indexed(unique=true)</code> and <code>@Indexed(unique=false)</code>.  </p>
  
  <p>I have a field that I wanted indexed so I can execute fast queries against it.  In this case it's email address which generally should be unique, but it's possible for the emailAddress to be null for a period.  </p>
  
  <p>However, once one record as a null emailAddress I can't have any other records with a null emailAddress.  Spring Data refuses to insert any additional records with <code>null</code> <strong>emailAddresses</strong>.  And it fails to throw anything that it didn't work.  </p>
  
  <p>Right now I have it set to <code>unique=true</code>, but I'm contemplating setting it to <code>unique=false</code> to get around this problem.  </p>
  
  <p>Will this fix the problem? </p>
  
  <p>And what other problems could I be adding by relaxing this? </p>
  
  <p>Will MongoDB allow me to have multiple email addresses that are equal and still be fast at querying?</p>