I don't know how much you guys have looked into App Engine datastore indices, but a tricky aspect of it just bit me, so I have changed our policy.
https://code.google.com/appengine/docs/java/datastore/queries.html Basically, when you do certain queries such as searching in alphabetical order, the datastore needs a pre-built index. The developer needs to manually specify exactly which tables to index, which fields and the sort orders, etc. If you don't specify it, you get a DatastoreNeedIndexException at runtime. You put these in war/WEB-INF/datastore-indexes.xml. *However*, by default the app engine dev mode automatically generates the indices for you whenever one is needed, and saves them in war/WEB-INF/appengine-generated/datastore-indexes-auto.xml. So in practice, on the dev mode, you never get this exception. When you upload to the production environment, it copies datastore-indexes-auto.xml as well, so you *still* don't usually see these exceptions in practice. However, this is quite brittle. If you recently cleaned out your appengine-generated (as I did), or if you are uploading from a PC that hasn't fully tested the program in dev mode, then you can upload a version of the program that doesn't work. Therefore, the policy change is that I have *removed* the automatic generation of indices. This means *you can now get DatastoreNeedIndexExceptions* on the development mode, and you need to know how to deal with them. If you do get such an exception, this is a good thing: it means the dev mode is showing exactly what will happen on production. It's quite easy to fix. There are instructions in war/WEB-INF/datastore-indexes.xml. 1. You don't seem to need to restart the dev server. 2. Open up war/WEB-INF/datastore-indexes.xml in your text editor 3. In datastore-indexes.xml, set autoGenerated="true". 4. Test the program again; this time you won't get the DatastoreNeedIndexException. 5. Open up war/WEB-INF/appengine-generated/datastore-indexes-auto.xml. There you will see a new index. 6. Copy-paste the new index (anything that is not there already) into datastore-indexes.xml. 7. *Be sure to* set autoGenerated="false" again or nobody will see any more DatastoreNeedIndexExceptions. 8. Test the program again; you should not see any more DatastoreNeedIndexException. 9. Commit the changes.
-- Mailing list: https://launchpad.net/~mugle-dev Post to : [email protected] Unsubscribe : https://launchpad.net/~mugle-dev More help : https://help.launchpad.net/ListHelp

