如何解决GAE上的指数警告?

时间:2014-02-09 03:43:53

标签: google-app-engine google-cloud-datastore

我们几天前向我们的数据存储区引入了一个新模型。令人惊讶的是,我仍然得到了索引警告

W 2014-02-09 03:38:28.480
suspended generator run_to_queue(query.py:938) raised NeedIndexError(no matching index found.
The suggested index for this query is:
- kind: FeelTrackerRecord
  ancestor: yes
  properties:
  - name: timestamp)

W 2014-02-09 03:38:28.480
suspended generator helper(context.py:814) raised NeedIndexError(no matching index found.
The suggested index for this query is:
- kind: FeelTrackerRecord
  ancestor: yes
  properties:
  - name: timestamp)

即使索引是在DataStore Indexes

下提供的

enter image description here

indexes:

# AUTOGENERATED

# This index.yaml is automatically updated whenever the dev_appserver
# detects that a new type of query is run.  If you want to manage the
# index.yaml file manually, remove the above marker line (the line
# saying "# AUTOGENERATED").  If you want to manage some indexes
# manually, move them above the marker line.  The index.yaml file is
# automatically uploaded to the admin console when you next deploy
# your application using appcfg.py.


- kind: FeelTrackerRecord
  ancestor: yes
  properties:
  - name: record_date
  - name: timestamp

我错过了什么?

2 个答案:

答案 0 :(得分:3)

我终于找到了问题。

解决此问题的最佳方法是确保本地index.yaml为空(删除所有索引)。然后只需在localhost上运行您的GAE应用程序并按预期访问您的应用程序。 Http访问在浏览器上非常简单,如果需要通过REST进行GET / POST,您可以从终端使用curl

获取:

curl --user test@gmail.com:test123 http://localhost:8080/api/v1.0/records/1391944029

发表:

curl --user test@gmail.com:test123  http://localhost:8080/api/v1.0/records/1391944029 -d '{"records": [
        {
            "notes": "update", 
            "record_date": "2014-02-02", 
            "timestamp": 1391944929
        }
    ], "server_sync_timestamp": null}' -X POST -v -H "Accept: application/json" -H "Content-type: application/json"

GAE现在自动更新index.yaml并在其中添加正确的索引。

部署应用程序后,您需要清理旧索引。 这是通过终端完成的:

appcfg.py vacuum_indexes src

使用凭据登录后,它会询问您index.yaml中不再存在的旧索引以及是否应将其删除。按y继续。

答案 1 :(得分:0)

我在评论中提到您的索引与所需的索引不匹配。错误说

raised NeedIndexError(no matching index found.
The suggested index for this query is:
- kind: FeelTrackerRecord
  ancestor: yes
  properties:
  - name: timestamp)

但是,您列出的索引是不同的

- kind: FeelTrackerRecord
  ancestor: yes
  properties:
  - name: record_date
  - name: timestamp

你看到了区别吗?

只需添加列出的索引并更新索引。