Google Datastore综合索引问题 [英] Google Datastore Composite index issue

查看:260
本文介绍了Google Datastore综合索引问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

 线程main中的异常com.google.cloud.datastore.DatastoreException:no找到匹配索引。推荐索引是:
- kind:cp_outbox
属性:
- 名称:格式
- 名称:occasion_name
- 名称:sent_datetime
- name:状态
- name:send_date

在查询下运行时:



SELECT * FROM cp_outbox其中send_date< ='2018-03-14'且sent_datetime为空且format ='test1'且status = 0且occasion_name ='test'



所以我在查询中使用不等式运算符,并且我有复合索引:



但我仍然感到异常。



通过查看错误,我认为属性的排序是问题。如果这是真的,那么为什么这个顺序是重要的。



在此先感谢。

解决方案

div>

在提供查询时,属性顺序对组合索引是绝对重要的。该命令允许我们提供范围查询,而不必扫描索引表的大部分内容。作为一般规则,最终属性是您可以对不等式查询进行的操作,然后重命名属性顺序通过子句顺序定义您可以使用的顺序。



在你的查询中, send_date 就是你在做不等的事情,而你现有的组合索引只允许 occasion_name



如果您完全按照API返回的方式创建复合索引,则您的查询将起作用。


I am getting below exception :

Exception in thread "main" com.google.cloud.datastore.DatastoreException: no matching index found. recommended index is:
- kind: cp_outbox
  properties:
  - name: format
  - name: occasion_name
  - name: sent_datetime
  - name: status
  - name: send_date

While running below query :

SELECT * FROM cp_outbox where send_date <= '2018-03-14' and sent_datetime is null and format='test1' and status=0 and occasion_name='test'

So I am using inequality operator in query and I have composite index for that :

But still I am getting exception.

By looking at error I think the ordering of properties is the issue. If this is true then why this ordering is important.

Thanks in Advance.

解决方案

Property order absolutely matters for composite indexes when serving queries. The order is what allows us to serve range queries without having to scan through large sections of the index table. As a general rule, the final property is what you can do the inequality queries on, then the renaming property order defines the order by clause order you can use.

In your query send_date is what you are doing inequality on, whereas your existing composite index only allows for occasion_name.

If you create the composite index exactly as the API has returned your query will work.

这篇关于Google Datastore综合索引问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆