【发布时间】:2014-10-22 06:17:52
【问题描述】:
我正在 appengine 上使用 objectify,我尝试添加一个 cron 作业来删除所有超过一小时的临时实体:
Iterable<Key<Entry>> allKeys = ofy().load().type(Entry.class)
.filter("temporary", true)
.filter("createdAt", oneHourAgo).keys();
if(allKeys != null){
ofy().delete().keys(allKeys);
}
但我在 appengine 服务器上执行 cron 作业时总是遇到异常:
com.google.appengine.api.datastore.DatastoreNeedIndexException: no matching index found.
The suggested index for this query is:
<datastore-index kind="Entry" ancestor="false" source="manual">
<property name="temporary" direction="asc"/>
<property name="createdAt" direction="asc"/>
</datastore-index>
有人知道为什么会这样吗?如果我删除,这项工作就会起作用:
.filter("createdAt", oneHourAgo)
【问题讨论】:
-
数据存储中是否为“createdAt”创建了任何索引?
-
是的,索引是为两者创建的(createdAt 和temporary)!
标签: java google-app-engine cron objectify