Man*_*rma 7 google-app-engine google-cloud-datastore
我想测试我在Google数据存储区中创建的新实体.我正在尝试使用不等式执行GQL查询来检索数据存储区Web界面中的某些实体:
SELECT*FROM UserMatchingIndex WHERE age <25 AND wants_male = false AND wants_dating = false AND wants_friendship = false AND wants_age = 20
但我总是有一个错误:"GQL查询错误:您的数据存储区没有此查询所需的复合索引(开发人员提供的)." 而我已经定义了所需的复合索引!
UserMatchingIndex:年龄▲wants_male▲want_dating▲want_friendship▲want_age▲服务
UserMatchingIndex:年龄▲want_female▲want_dating▲want_friendship▲want_age▲服务
这些在index.yaml中定义如下:
- kind: UserMatchingIndex
ancestor: no
properties:
- name: age
- name: wants_male
- name: wants_dating
- name: wants_friendship
- name: wants_age
- kind: UserMatchingIndex
ancestor: no
properties:
- name: age
- name: wants_female
- name: wants_dating
- name: wants_friendship
- name: wants_age
Run Code Online (Sandbox Code Playgroud)
我真的不明白什么可能是错的......我已经为其他实体多次这样做了.如果你有一些线索,欢迎你.
该问题已提交给Google Cloud支持,这似乎是他们的问题,或者至少是一个尚未记录的限制。如下更改属性的顺序:
- kind: UserMatchingIndex
ancestor: no
properties:
- name: wants_male
- name: wants_dating
- name: wants_friendship
- name: wants_age
- name: age
Run Code Online (Sandbox Code Playgroud)
使查询工作。
编辑:谷歌支持的答案
“索引表的行首先按祖先排序,然后按属性值排序,并按索引定义中指定的顺序进行排序。在以下属性上定义了查询的最佳索引,该索引可以最有效地执行查询, 为了:
- 等式过滤器中使用的属性
- 不等式过滤器中使用的属性(不能超过一个)
- 排序顺序中使用的属性
这样可以确保查询的每次可能执行的所有结果都显示在表的连续行中。”
此限制应尽快记录在案。
归档时间: |
|
查看次数: |
3391 次 |
最近记录: |