gpt4 book ai didi

google-app-engine - 我无法查询 GQL 的 2 个属性,只有通配符有效

转载 作者:IT王子 更新时间:2023-10-29 00:45:38 25 4
gpt4 key购买 nike

我将 comment 实体存储在 Datastore 中,并使用 Datastore Viewer 查看存储的数据。

我可以做以下查询

select * from comment    
select __key__ from comment
select Subject from comment
select Comment from comment

但是查询不到

select Subject, Comment from comment
// Error: The suggested index for this query is:
// - kind: comment
// properties:
// - name: Comment
// - name: Subject
select __key__, Subject, Comment from comment
// Error: projections are not supported for the property: __key__

我找不到任何错误的引用。这些错误并没有告诉我太多。

我没有为这些实体设置任何键或索引。

Documentation讲述如下:

SELECT [DISTINCT] [* | <property list> | __key__]
[FROM <kind>]
[WHERE <condition> [AND <condition> ...]]
[ORDER BY <property> [ASC | DESC] [, <property> [ASC | DESC] ...]]
[LIMIT [<offset>,]<count>]
[OFFSET <offset>]

<property list> := <property> [, <property> ...]
<condition> := <property> {< | <= | > | >= | = | != } <value>
<condition> := <property> IN <list>
<condition> := ANCESTOR IS <entity or key>
<list> := (<value> [, <value> ...]])

Subject, Comment - 是属性列表及其有效查询。但事实并非如此。我从 Go 代码创建了实体。

最佳答案

投影查询有一些限制。在projection-doc提到“只能投影索引属性”

第一条错误消息准确地表明Subject, Comment 的组合索引尚不存在。您可以通过添加

手动创建索引
- kind: comment
properties:
- name: Comment
- name: Subject

到项目根文件夹中的 index.yaml。请看一下 index spec和投影文档。

// Error: projections are not supported for the property: __key__

实体 由 GetAll 方法返回。不要将它们放在您的投影中。

keys, err := q.GetAll(c, &people)

我还不能发布超过 2 个链接,所以请在数据存储引用中查找更多详细信息。

关于google-app-engine - 我无法查询 GQL 的 2 个属性,只有通配符有效,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21019092/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com