java - Objectify:排序查询结果 ("no matching index found"错误)

标签 java gwt google-cloud-datastore requestfactory objectify

我在执行下面查询的浏览器上收到此错误,但没有 ".order("position") 它工作(但结果显然没有排序)。

Uncaught com.google.web.bindery.event.shared.UmbrellaException: Exception caught: Server Error: no matching index found.
The suggested index for this query is:
    <datastore-index kind="Box" ancestor="false" source="manual">
        <property name="diagram_id" direction="asc"/>
        <property name="position" direction="asc"/>
    </datastore-index>

BoxDao.java

public List<Box> listFromDiagram(String diagramId)
{
    Objectify ofy = ObjectifyService.begin();
    // List of boxes of that diagram ordered by position asc
    Query<Box> q=ofy.query(Box.class).filter("diagram_id",diagramId).order("position");
    List<Box> results = q.list();

    return results;
}

Box.java

import com.googlecode.objectify.annotation.Entity;
import com.googlecode.objectify.annotation.Indexed;

@Entity
public class Box extends DatastoreObject{
    @Indexed private String boxId;
    @Indexed private String diagram_id;
    private String title;
    @Indexed private int position;
[...]
}

文件“datastore-indexes.xml”是空的……有什么想法吗?谢谢

最佳答案

您需要一个多属性索引(您按一个属性过滤并按另一个属性排序)。错误消息告诉您需要在 datastore-indexes.xml 中放入什么。有关概念性概述,请参阅:

https://code.google.com/p/objectify-appengine/wiki/Concepts#Indexes

我建议您也点击 Google 文档的链接。

关于java - Objectify:排序查询结果 ("no matching index found"错误),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13178460/

相关文章:

java - Android opengl 在绘制调用后修改顶点数组

java - 警告 :/%3C%=request. getContextPath()%%3E/trailpath/trailpath.nocache.js : java. lang.NumberFormatException: =r

java - 像普通网页一样的整页 GWT 布局

google-app-engine - 如何备份 Google App Engine 全文搜索文档?

java - 如何使 Java 数组表现得像 JavaScript 数组?

Java 打印带有两个分隔符的数组

java - ServletFileUpload,GWT 不会破坏大文件

java - 如果我知道 ID,如何通过其唯一 ID 获取数据存储实体?

python - Google 数据存储 ID 是一个长 unicode 而不是整数

java - 默认值取决于列类型 mysql