I suppose that "crashing" means throwing an exception or something like that. If so, you should set the autoGenerate
attribute in WEB-INF/datastore-indexes.xml
to false.
Example WEB-INF/datastore-indexes.xml
:
<datastore-indexes autoGenerate="false"> </datastore-indexes>
Setting autoGenerate
to false will make a query that requires the composite index to throw an exception. Code example:
try { Query q = new Query("Action") .addSort("encrypter", Query.SortDirection.ASCENDING) .addSort("requester", Query.SortDirection.ASCENDING) .addSort("time", Query.SortDirection.DESCENDING); //...snip... } catch (Exception e) { log.severe(e.toString()); }
I tested this and got an exception logged as expected:
SEVERE: com.google.appengine.api.datastore.DatastoreNeedIndexException: Query com.google.appengine.api.datastore.dev.LocalCompositeIndexManager$IndexComponentsO nlyQuery@f9f81ad3 requires a composite index that is not defined. You must update C:\appengine-java-sdk\dev\core1\war\WEB-INF\datastore-indexes.xml or enable au toGenerate to have it automatically added. The suggested index for this query is: <datastore-index kind="Action" ancestor="false" source="manual"> <property name="encrypter" direction="asc"/> <property name="requester" direction="asc"/> <property name="time" direction="desc"/> </datastore-index>
See datastore-indexes.xml for more information.
source share