首先我创建一个 index.yaml
- kind: Tarifa 2014
ancestor: yes
properties:
- name: Date
direction: desc
- kind: Tarifa 2014
ancestor: yes
properties:
- name: Division
- name: Heat
- name: Date
direction: desc
然后我把一些数据放进去
key := datastore.NewKey(s.Context, "Tarifa 2014", "", 0, s.Root)
key, err = datastore.Put(s.Context, key, m)
简单的查询工作,
key := datastore.NewKey(s.Context, "Tarifa 2014", "", id, s.Root)
err = datastore.Get(s.Context, key, &m)
但这不是因为我的索引仍然是空的吗?
datastore.NewQuery(e).Ancestor(s.Root).Filter("Division =", d).Filter("Heat =", h).Order("-Date")
同样如此,也行不通?
datastore.NewQuery(e).Ancestor(s.Root).Order("-Date")
我在 appspot.com 上的索引看起来像这样?
我的数据存储在 appspot.com 上看起来像这样
请注意,在 localhost:8080 上所有查询都工作正常?
最佳答案
由于不清楚的原因,如果我使用 Namespace
,索引查询会在 appspot.com 上中断
c2 := endpoints.NewContext(r)
c, err := appengine.Namespace(c2, "")
if err != nil {return err}
您需要在没有命名空间的情况下直接使用端点上下文。
c := endpoints.NewContext(r)
关于google-app-engine - 我的数据存储在 appspot 上没有索引条目?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24595487/