google 数据存储同时使用顺序和过滤器

google datastore use order and filter together

我想根据日期和 condition.But 对 google 数据存储中的记录进行排序,当我在 Nodejs 代码中尝试此操作时,出现错误。

datastoreError 中的错误:9 FAILED_PRECONDITION:找不到匹配的索引。推荐索引为:

我的密码是

异步函数 upsertVersions(namespaceOrKind, kind) {

const query = datastore.createQuery(namespaceOrKind, kind).order('created').filter('apiName', '=', 'retail');
return await datastore.runQuery(query);

}

属性的数据类型 'created' 是时间戳(日期和时间),'apiName' 是字符串。当我只使用过滤器时,我能够得到结果,但是当我同时使用过滤器并且没有订购结果时,我想根据创建日期和传递的 apiName 获得结果。

如有任何建议,我们将不胜感激。

这个问题现在已经解决了,我已经为字段创建了索引,之后它工作正常。它的数据存储将不支持基于某些条件的没有索引的查询,在我的情况下它需要索引。