java - App Engine 不生成复合索引

标签 java google-app-engine

我正在遵循 Udacity 的使用 Java 开发可扩展应用程序教程,并尝试通过多个属性创建查询,但它不起作用。

这是 Api 方法:

@ApiMethod(name = "filterPlayground",path = "filterPlayground",httpMethod = HttpMethod.POST)
public List<Conference> filterPlayground()
{
    Query<Conference>query = ofy().load().type(Conference.class).order("name");
    query.filter("city = ","London");
    query.filter("topics =", "Medical Innovations");
    query.filter("month = ", 6);

    return query.list();
}

以下是 session 模型中的字段:

private static final String DEFAULT_CITY = "Default City";

@Index private List<String> topics;
@Index(IfNotDefault.class) private String city = DEFAULT_CITY;
@Index private int month;

它只显示所有 session 。我不明白为什么这不起作用。顺便说一句,当我部署到本地主机时,datastore-indexes-auto.xml 始终为空。

这里是测试的链接: https://apis-explorer.appspot.com/apis-explorer/?base=https://deft-envoy-650.appspot.com/_ah/api#p/conference/v1/conference.filterPlayground?_h=3&

我希望有人能帮助我解决这个问题。 问候,

最佳答案

我也在学习同一门类(class),并且在这一点上也遇到了困难。无论我做什么,datastore-indexes-auto.xml 都没有被创建!

我的解决方法如下:

1) 在文件夹/conference/src/main/webapp/WEB-INF/中创建一个 datastore-indexes.xml 文件,内容如下:

<?xml version="1.0" encoding="UTF-8"?>
<datastore-indexes
autoGenerate="true">
    <datastore-index kind="Conference" ancestor="false">
        <property name="city" direction="asc" />
        <property name="topics" direction="asc" />
        <property name="month" direction="asc" />
        <property name="name" direction="asc" />
    </datastore-index>
</datastore-indexes>

(但是,autoGenerate="true"似乎没有效果)

2) 部署到appsot

这样,您上面发布的查询就适合我。我同意 - 类(class)的 GAE 版本似乎有些不同,因为我遇到了几个问题(即我似乎没有本地数据存储,但每个本地主机执行都在访问我的 appspot 数据存储..) .

关于java - App Engine 不生成复合索引,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25445166/

相关文章:

java - 如何添加和忽略 json 响应的字段

javax 与 java 包

java - 带有 Java 和 ReactJS 服务器端渲染的微服务 UI 前端

java - 使用 Key.Id 查询 Google App Engine 数据存储

google-app-engine - Google Analytics API 使用哪个时区?

java - 将列表中的所有字符串打印成单个字符串的最优雅/简洁的方法是什么?

java - 如何从Java中的/proc/PID/net/tcp和/proc/PID/net/tcp6文件解析IP地址?

google-app-engine - ndb 的缓存如何处理压缩属性?

python - 使用 python/GAE 对 cookie 进行存在性检查的最佳方法是什么?

google-app-engine - 纯 Appengine 项目大量使用计算引擎 API?