The following query in Datastore return the expected number of results:
SELECT timestamp from leadgenie_campaign_model_dev where campaign = "3667f39d-a3ff-4acb-b1ca-6f730bbc7989"
This query is backed by an index, which allows for the projection.
But this one doesn't return any results, despite the fact that an index also exists. attrs
is a JSON string
SELECT timestamp, attrs from leadgenie_campaign_model_dev where campaign = "3667f39d-a3ff-4acb-b1ca-6f730bbc7989"
Here's the spec for the indexes:
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
The solution was to include the subproperty in the query, after creating an index for those properties specifically.
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