title: Java morphia - query by values in a list field
body: <p>Not sure if this is possible, but here goes.</p>
  
  <p>I have a MongoDB (using morphia to access it) with a table like the following (simplified for this example, but the concept is the same):</p>
  
  <pre><code>{ Name : "Robert", NickNames : [ "Bob", "Twinkletoes" ] }
  { Name : "Trevor", NickNames : [ "Bob", "Mad man", "Tweedledee" ] }
  { Name : "Samuel", NickNames : [ "Sam" ] }
  { Name : "Patrick", NickNames : [ "Bob", "Mad man" ] }
  { Name : "Mark", NickNames : [ "Adam", "Bob", "Georg" ] }
  </code></pre>
  
  <p>And for the purpose of this example let's say the nicknames are always in alphabetical order and the position where the nickname lies is relevent.</p>
  
  <p>So, as we can see every person record can have a different number of nicknames in the list. How can I perform the following searches:</p>
  
  <ul>
  <li><p>Give me all people with the first nickname "Bob" and the second nickname "Mad man" (i.e. Person.Nicknames[0] = "Bob" &amp;&amp; Person.Nicknames[1] = "Mad man")</p>
  
  <p>Should return 2 records - Trevor and Patrick.</p></li>
  <li><p>Give me all people with the first nickname "Bob" (i.e. Person.Nicknames[0] = "Bob")</p>
  
  <p>Should return 3 records - Robert, Trevor and Patrick.</p></li>
  </ul>
  
  <p>Note that Mark wasn't returned because he his nickname of "Bob" wasn't in the first index. </p>
  
  <p>Is there any way to do this?</p>