php 的等式运算符在 GQL 数据存储中不起作用

Equality operators not working in GQL datastore for php

这是 GQL 中的一个查询,它在 modified > timestamp

时不起作用
        $query = $ds->query()
           ->kind('Video')
           ->filter('email', '=', $email)
           ->filter('lat', '=', $lat)
           ->filter('lng', '=', $lng)
           ->filter('modified', '>', 1505807001);

        $result = $ds->runQuery($query);

如果跳过大于时间戳的查询,查询将正常工作。否则无效。

Returns异常。摘录如下:

{
  "error": {
   "code": 400,
    "message": "no matching index found. recommended index is:\n- kind: 
      Video\n  propert (truncated...)

如有任何帮助,我们将不胜感激。

您需要为查询添加显式复合索引(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 是地理点,您可能想要使用类似地理散列 (http://hitching.net/2009/11/10/scalable-fast-accurate-geo-apps-using-google-app-engine-geohash-faultline-correction/) 的东西。