【问题标题】:Google App Engine Java - Indexes and KeysGoogle App Engine Java - 索引和键
【发布时间】:2012-09-05 19:04:39
【问题描述】:

向数据存储索引添加键有一些限制吗?

我有 Test.java

@EntityBean(entityGroup="TestRoot", entityGroupKeyName="TestList")
public class Test implements Serializable, JSONConvertible {
    @Property(key=true,indexable=true)
    private String keyName;
    @Property(indexable=true)
    private String userCode;
    @Property(indexable=true)
    private String name;
...

在我的 datastore-indexes.xml 中:

<datastore-index kind="Flight" ancestor="true">
    <property name="keyName" direction="desc"/>
</datastore-index>

<datastore-index kind="Flight" ancestor="true" source="manual">
    <property name="keyName" direction="asc"/>
</datastore-index>

<datastore-index kind="Flight" ancestor="true">
    <property name="userCode" direction="desc"/>
</datastore-index>

<datastore-index kind="Flight" ancestor="true" source="manual">
    <property name="userCode" direction="asc"/>
</datastore-index>

<datastore-index kind="Flight" ancestor="true">
    <property name="name" direction="desc"/>
</datastore-index>

<datastore-index kind="Flight" ancestor="true" source="manual">
    <property name="name" direction="asc"/>
</datastore-index>

我的所有索引都处于服务状态

当我订购测试列表时,“userCode”和“name”可以正常工作,但“keyName”不能正常工作,有什么帮助吗?

【问题讨论】:

  • 您如何将@EntityBean 与 Datastore 一起使用?

标签: java google-app-engine indexing


【解决方案1】:

您应该阅读有关Key Filters 的信息。默认情况下,GAE 已经对键进行了升序索引,因此无需构建。对于键的降序索引,试试这个:

<datastore-index kind="Flight" ancestor="true">
    <property name="__key__" direction="desc"/>
</datastore-index>

【讨论】:

    猜你喜欢
    • 2015-07-22
    • 2019-01-19
    • 1970-01-01
    • 1970-01-01
    • 2017-01-15
    • 2015-03-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多