GAE如何使用HttpClient调用doGet-Method

时间:2015-06-24 16:32:16

标签: java android google-app-engine

我想从Datastore返回myHighscores: 即:保罗,1200       汤姆,1000       凯文,800

private void returnHighscores(HttpServletResponse resp, String game, int max) throws IOException {
    DatastoreService datastore = DatastoreServiceFactory.getDatastoreService();
    Key gameKey = KeyFactory.createKey("game", game);
    Query query = new Query("highscore", gameKey);
    query.addSort("points", Query.SortDirection.DESCENDING);
    List<Entity> highscores = datastore.prepare(query).asList(FetchOptions.Builder.withLimit(max));

    for(Entity e : highscores) {
        resp.getWriter().println(e.getProperty("name") + "," + e.getProperty("points"));
    }
}

但如果我尝试运行此操作,我会收到错误:

  

com.google.appengine.api.datastore.DatastoreNeedIndexException:找不到匹配的索引。此查询的建议索引是:

 <datastore-index kind="highscore" ancestor="true" source="manual"> <property name="points" direction="desc"/> </datastore-index>

我该如何解决这个问题?

0 个答案:

没有答案