以下是GQL中的查询,该查询无效已修改>时间戳
$query = $ds->query()
->kind('Video')
->filter('email', '=', $email)
->filter('lat', '=', $lat)
->filter('lng', '=', $lng)
->filter('modified', '>', 1505807001);
$result = $ds->runQuery($query);
如果跳过大于时间戳,查询将正常工作。否则不起作用。
返回异常。摘录如下:
{
"error": {
"code": 400,
"message": "no matching index found. recommended index is:\n- kind:
Video\n propert (truncated...)
对此的任何帮助将不胜感激。
答案 0 :(得分:2)
您需要为查询添加显式复合索引(https://cloud.google.com/datastore/docs/concepts/indexes)。
如果没有不平等,Cloud Datastore可以使用内置索引来进行查询,但由于时间戳不平等,Cloud Datastore无法进行查询。
您可能想要一个索引定义,如:
indexes:
- kind: Video
properties:
- name: email
direction: desc
- name: lat
direction: desc
- name: lng
direction: desc
- name: modified
direction: asc
作为一个随便,如果lat& lg是地理位置,你可能想要使用geohashing(http://hitching.net/2009/11/10/scalable-fast-accurate-geo-apps-using-google-app-engine-geohash-faultline-correction/)之类的东西。