title: How does appengine's data store query and index multi-value properties?
body: <p>Lets say I have a Photo class containing a multi-valued property for tags and a date field.</p>
  
  <p>I would like to allow the user to perform a query based on tags (using only a AND operator for more then 1 tag).</p>
  
  <p>For example lets say a user searches for a rainy day.
  Select * from Photo where tag='clouds' AND tag='rainy'</p>
  
  <p>How does the zig-zag merge work? I know that two scans are performed, and based on if the keys from both searches point to the same Photo then it's returned. Does this happen in parallel however? Ex: While Search 1 finds a photo that contains tag 'clouds' , Search 2 is finding the first photo that contains tag "rainy". When both searches are done, it becomes synchronous. Search 1 then continues it's scan until it hits the same key as S2. Then while the keys for each search are the same, the photo is returned, and the "cursor" is moved along 1 step for each search?</p>
  
  <p>Secondly, does defining multiple indexes speed up these sort of queries? Ex, if I wanted to allow up to 4 tags then I would need to define the indexes such as:
  Index(Photo)
  Index(Photo, tag)
  Index(Photo, tag,tag)
  Index(Photo, tag,tag,tag)
  Index(Photo, tag,tag,tag,tag)
  Then, performing the same query above will be quicker?</p>
  
  <p>Also, using our original query, lets say we have Millions of photos tagged as cloudy, but only two are tagged as rainy. Does this mean zig-zag will perform relatively slow? Since one of the searches will try to find a matching exist? Even worse, if we have one million photos tagged "rainy" and one million are tagged "cloudly" yet no single photo have both tags in them. Will defining the above index's fix this issue?</p>
  
  <p>Lastly, lets say a photo has 100 tags. Does that mean all the index's above have to include EVERY combination of the 100 tags? </p>
  
  <p>I know there are got-yas (such as a entity can only be indexed 5000 times, and a single multi-valued property can only be indexed a 1000 times).  </p>