在基于Android-Studio的项目中为AppEngine创建复合索引

时间:2015-12-19 21:00:41

标签: google-app-engine android-studio google-cloud-endpoints google-cloud-datastore objectify

我使用Android Studio创建了Android项目及其后端AppEngine端点对应项。我有一个数据存储区,我正在使用Objectify。系统工作得很好,直到我在查询中添加了一个过滤器(仅显示特定的给定电子邮件)。

Query<Report> query = ofy().load().type(Report.class).filter("email", user.getEmail()).order("email").order("-when").limit(limit);

这是POJO数据存储区实体:

@Entity
public class Report {
    @Id
    Long id;

    String who;

    @Index
    Date when;

    String what;

    @Index
    String email;
}

但是,当我尝试测试时,我从Google API资源管理器收到了这样的错误:

com.google.appengine.api.datastore.DatastoreNeedIndexException: no matching index found.
The suggested index for this query is:
    <datastore-index kind=\"AccessReport\" ancestor=\"false\" source=\"manual\">
    <property name=\"email\" direction=\"asc\"/>
    <property name=\"when\" direction=\"desc\"/>
    </datastore-index>

据我了解,我只需要创建一个复合索引,包括特定字段的电子邮件和时间,以及它们的特定排序方向。

但是,我发现的大多数文档都告诉我要编辑datastore-indexes.xml

  

App Engine预定义了实体每个属性的简单索引。一个   App Engine应用程序可以在索引中定义更多自定义索引   名为datastore-indexes.xml的配置文件,在其中生成   您的应用程序&war / WEB-INF / appengine生成的目录。

不幸的是,这个文件似乎不存在于我的项目中。

是否有人熟悉使用Android Studio时更改此方法的方法?

0 个答案:

没有答案
相关问题