1
votes

Kind name: invoice_header

Name/ID                       :id=4829628648652800
amount                        :2900
booking_ids                   :1,2
created_at                    :2018-09-04 10:20:30
discount_amount               :23
due_amount                    :9999
indicator                     :PO
invoice_date                  :2018-09-04
invoice_id                    :451
issued_to                     :P
location_id                   :12
net_payable_amount            :999
order_or_po_id                :533
paid_amount                   :555
partner_id                    :400
payment_mode_promotion_amount :0
status                        :NP
tax_amount                    :34
updated_at                    : 

I tried to fetch the data using below GQL Query from the above kind but I got the following error.

GQL query error: Your Datastore does not have the composite index (developer- supplied) required for this query.

select invoice_date from invoice_header where location_id ='12' and invoice_date >= '2018-09-01' and invoice_date <= '2018-09-05'
1

1 Answers

0
votes

Have you added an index file to your application?

As it is stated in the documentation [1], every Cloud Datastore query made by an application needs a corresponding index. Indexes for simple queries, such as queries over a single property, are created automatically. Indexes for complex queries must be defined in a configuration file named index.yaml. This file is uploaded with the application to create indexes in Cloud Datastore.

Composite indexes support complex queries and are defined in an index configuration file (index.yaml).

In your case you need to add a composite index that includes location_id and invoice_date properties. This is an example of the index.yaml:

indexes: - kind: invoice_header properties: - name: location_id direction: asc - name: invoice_date direction: asc

When you are done modifying your index configuration file, run the "gcloud datastore create-indexes" command to place the indexes into service.

In [2] you will find a broader explanation about the indexes.

Cheers.