数据存储区中的以下查询返回预期的结果数:
SELECT timestamp from leadgenie_campaign_model_dev where campaign = "3667f39d-a3ff-4acb-b1ca-6f730bbc7989"
此查询由索引支持,该索引允许进行投影。
尽管存在索引,但此结果不会返回任何结果。 attrs
是JSON字符串
SELECT timestamp, attrs from leadgenie_campaign_model_dev where campaign = "3667f39d-a3ff-4acb-b1ca-6f730bbc7989"
这是索引的规范:
indexes:
- kind: leadgenie_campaign_model_dev
properties:
- name: campaign
- name: attrs
- name: timestamp
- kind: leadgenie_campaign_model_dev
properties:
- name: campaign
- name: timestamp
- name: attrs
- kind: leadgenie_campaign_model_dev
properties:
- name: campaign
- name: timestamp
答案 0 :(得分:0)
您的attrs字段是否超过1500个字节?这是对要索引的字符串属性的限制。参见https://cloud.google.com/datastore/docs/concepts/limits。
答案 1 :(得分:0)
解决方案是在专门为这些属性创建索引之后,将子属性包含在查询中。
SELECT timestamp, attrs.score, attrs.sz from leadgenie_campaign_model_dev where campaign = "3667f39d-a3ff-4acb-b1ca-6f730bbc7989"
google.api_core.exceptions.FailedPrecondition: 400 no matching index found. recommended index is:
- kind: leadgenie_campaign_model_dev
properties:
- name: campaign
- name: attrs.score
- name: attrs.sz
- name: timestamp