下面的代码片断我已经添加用于过滤工作和排序的数据存储区的记录,排序和筛选没有在谷歌应用程序引擎
DatastoreService datastore = DatastoreServiceFactory.getDatastoreService();
Filter propertyFilter =
new FilterPredicate("stockId", FilterOperator.EQUAL, stockId);
com.google.appengine.api.datastore.Query q = new com.google.appengine.api.datastore.Query("MessageEntity")
.setFilter(propertyFilter).addSort("messageId", SortDirection.ASCENDING);
List<Entity> results=
datastore.prepare(q).asList(FetchOptions.Builder.withLimit(10));
如果删除
addSort(“MESSAGEID”, SortDirection.ASCENDING)
查询运行良好,但如果添加上面的行,App引擎不会给出任何响应。我在这里错过了什么?
我已经添加@ MessageEntity的messageId上的索引是否不够? –
它只适用于新实体。您必须重新保存现有实体以使它们重新编制索引。 –
ohhh ...谢谢...我会再次检查。对于索引,我正在检查https://cloud.google.com/appengine/docs/flexible/java/configuring-datastore-indexes-with-index-yaml哪里严格我需要把它放在我的项目和任何模式建议? –