2017-09-19 35 views
1

這裏是GQL查詢未在修改工作>時間戳平等運營商不GQL的數據存儲工作PHP

 $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/)。