Java Reference
In-Depth Information
Building Indexes
At runtime, if App Engine executes a query with no corresponding index, it will fail
miserably. By default, App Engine builds a number of simple indexes for you. For
more complex indexes, you will have to build them manually in the index
configuration file, as shown in Listing 7-2.
Listing 7-2. Sample datastore-index.xml file
<?xml version="1.0" encoding="utf-8"?>
<datastore-indexes
xmlns=" http://appengine.google.com/ns/datastore-indexes/1.0"
autoGenerate="true">
<datastore-index kind="Contact" ancestor="false">
<property name="countryName" direction="asc" />
</datastore-index>
</datastore-indexes>
Indexes are built automatically by App Engine for queries that contain:
Single property inequality filters
Only one property sort order (ascending or descending) and no filters
Inequality or range filters on keys and equality filters on properties
Only ancestor and equality filters
You must specify in the index configuration file any queries containing:
Multiple sort orders
Inequality and ancestor filters
A sort order on multiple keys in descending order
One or more inequality filters on a property and one or more equality
filters over the properties
Creating Indexes In Development Mode
During development, App Engines tries to create your indexes for you in the
configuration file. If the development web server encounters a query that does not have
a corresponding index, it will try to create an index for you automatically. If your unit
tests call every possible query for your application, the generated configuration file will
contain a complete set of all indexes. This is where confusion creeps into the process. If
 
Search WWH ::




Custom Search