如何使用GQL从Google Cloud Platform获取索引/列数据(Google查询语言)

问题描述 投票:1回答:1

种类名称: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                    : 

我试图从上面的GQL查询中获取数据,但是我收到了以下错误。

GQL查询错误:您的数据存储区没有此查询所需的复合索引(开发人员提供)。

select invoice_date from invoice_header where location_id ='12' and invoice_date >= '2018-09-01' and invoice_date <= '2018-09-05'
google-cloud-platform google-cloud-datastore
1个回答
0
投票

您是否已将索引文件添加到应用程序中?

正如文档[1]中所述,应用程序发出的每个Cloud Datastore查询都需要相应的索引。将自动创建简单查询的索引,例如单个属性上的查询。必须在名为index.yaml的配置文件中定义复杂查询的索引。此文件随应用程序一起上载,以在Cloud Datastore中创建索引。

复合索引支持复杂查询,并在索引配置文件(index.yaml)中定义。

在您的情况下,您需要添加包含location_id和invoice_date属性的复合索引。这是index.yaml的一个例子:

索引: - 种类:invoice_header属性: - name:location_id方向:asc - name:invoice_date方向:asc

完成索引配置文件的修改后,运行“gcloud datastore create-indexes”命令将索引置于服务中。

[2],你会找到关于指数的更广泛的解释。

干杯。

© www.soinside.com 2019 - 2024. All rights reserved.