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



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

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

如文档 [1] 中所述,应用程序进行的每个云数据存储查询都需要相应的索引。简单查询(如对单个属性的查询(的索引是自动创建的。复杂查询的索引必须在名为 index.yaml 的配置文件中定义。此文件随应用程序一起上传,以在云数据存储中创建索引。

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

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

指标: - 种类:invoice_header 性能: - 名称:location_id 方向: ASC - 名称:invoice_date 方向: ASC

修改完索引配置文件后,运行"gcloud 数据存储创建索引"命令以将索引放入服务中。

在 [2] 中,您将找到有关索引的更广泛解释。

干杯。

相关内容

最新更新