Hi Google App Engine team,

Lets say I have an Entity with a few properties:

@Entity
public class Animal{

  private String domain;
  private String kingdom;
  private String phylum;
  private String class;
  private String order;
  private String family;
  private String genus;
  private String species;
  private String classifier;

  private Date classifiedDate;
  private Date dateEntered;

  //getters + setters ...

}

If I want to search on say, domain, kingdom, class and dateEntered
with equality google docs suggest I don't need an index, but strangely
on some values - dateEntered = 2007 + any value of the properties I
get
DatastoreNeedIndexException but not for  dateEntered = 2006 or 2008. I
would have expected to get the error for all values where an index was
not in place or no error at all. Have i done something wrong here?

Also is it true that I need to specify an index (ok even auto
generated) for every query where a sort order is specified?

so for instance if I want to query on any domain=something ordered by
classifiedDate descending that's one index:
    <datastore-index kind="Animal" ancestor="false" >
        <property name="domain" direction="asc"/>
        <property name="classifiedDate " direction="desc"/>
    </datastore-index>

but if I wanted to query on any domain=something and
kingdom=otherThing ordered by classifiedDate  that would be two
indexs:
   <datastore-index kind="Animal" ancestor="false" >
        <property name="domain" direction="asc"/>
        <property name="kingdom" direction="asc"/>
        <property name="classifiedDate " direction="desc"/>
    </datastore-index>

   <datastore-index kind="Animal" ancestor="false" >
        <property name="kingdom" direction="asc"/>
        <property name="domain" direction="asc"/>
        <property name="classifiedDate " direction="desc"/>
    </datastore-index>

because app engine treats property ordering as important?

I guess I could always order the query properties myself to ensure no
index is duplicated and then for small numbers of properties this
isn't too bad.

If I wanted to optionally search for kingdoms or domains or both
ordered by classifiedDate   the index definition would be
    <datastore-index kind="Animal" ancestor="false" >
        <property name="domain" direction="asc"/>
        <property name="classifiedDate " direction="desc"/>
    </datastore-index>
    <datastore-index kind="Animal" ancestor="false" >
        <property name="kingdom" direction="asc"/>
        <property name="classifiedDate " direction="desc"/>
    </datastore-index>
  <datastore-index kind="Animal" ancestor="false" >
        <property name="domain" direction="asc"/>
        <property name="kingdom" direction="asc"/>
        <property name="classifiedDate " direction="desc"/>
    </datastore-index>

But, If I wanted to search on any combination of, say, 3 properties +
an order field this would be some 8 index definitions,

5 properties + an order would mean 32 definitions.

9 entity properties and order on classifiedDate would be some 512(!!)
different index definitions. If I wanted ascending as well as
descending order on classifiedDate  then I have to double that - 1024
definitions. and if I wanted to order on the query (optionally) as
dateEntered  ascending or descending instead then thats double again
-  2048. These seems crazy just to query on 9 difference properties.
Or have I got it badly wrong?

Can I just create the  4 indexes  :
     <datastore-index kind="Animal" ancestor="false" >
        <property name="classifiedDate " direction="desc"/>
    </datastore-index>

       <datastore-index kind="Animal" ancestor="false" >
        <property name="classifiedDate " direction="asc"/>
    </datastore-index>

    <datastore-index kind="Animal" ancestor="false" >
        <property name="dateEntered " direction="desc"/>
    </datastore-index>

    <datastore-index kind="Animal" ancestor="false" >
        <property name="dateEntered " direction="asc"/>
    </datastore-index>

if I'm doing only equality filters for 9 other fields? Obviously I
don't care about ordering results which will always be
="someEnteredValue".

cheers,
Alex.

-- 
You received this message because you are subscribed to the Google Groups 
"Google App Engine" group.
To post to this group, send email to google-appengine@googlegroups.com.
To unsubscribe from this group, send email to 
google-appengine+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-appengine?hl=en.

Reply via email to