我正在努力使用 GAE Guestbook 演示应用程序。我没有做任何修改。我在本地运行它,但是当我部署它时,出现以下错误:
com.google.appengine.api.datastore.DatastoreNeedIndexException: no matching index found. recommended index is:
- kind: Greeting
ancestor: yes
properties:
- name: date
direction: desc
The suggested index for this query is:
<datastore-index kind="Greeting" ancestor="true" source="manual">
<property name="date" direction="desc"/>
</datastore-index>
在本地运行时,会在 target/--SNAPSHOT/WEB-INF/appengine-generate 目录中生成 datastore-indexes-auto.xml。该文件完全包含所需的索引描述:
<datastore-indexes>
<!-- Used 1 time in query history -->
<datastore-index kind="Greeting" ancestor="true">
<property name="date" direction="desc" />
</datastore-index>
</datastore-indexes>
但是,应用程序无论如何都会抛出上述错误。
我还尝试将其从自动生成的 xml 文件移动到手动 xml (datastore-indexes.xml) 文件。
当我通过 mvn -e appengine:deploy
部署时,没有收到错误或警告:
...
[INFO] GCLOUD: Jan 02, 2017 8:01:14 PM com.google.apphosting.utils.config.IndexesXmlReader readConfigXml
[INFO] GCLOUD: INFO: Successfully processed /Users/stephanhofmann/Projects/mvntestapp/target/mvntestapp-1.0-SNAPSHOT/WEB-INF/datastore-indexes.xml
[INFO] GCLOUD: Jan 02, 2017 8:01:14 PM com.google.apphosting.utils.config.IndexesXmlReader readConfigXml
[INFO] GCLOUD: INFO: Successfully processed /Users/stephanhofmann/Projects/mvntestapp/target/mvntestapp-1.0-SNAPSHOT/WEB-INF/appengine-generated/datastore-indexes-auto.xml
...
无论如何,当我在“数据存储”>“索引”下检查时,Google 开发者控制台不会显示任何“复合”索引。我等了30多分钟(而且还没有数据,所以索引应该很快)。
不确定它是否是综合索引并且应该显示在此处,但应用程序缺少索引,我陷入困境。
非常感谢任何帮助。
最佳答案
我在使用mvn appengine:deploy
时遇到了同样的问题。然后我意识到我必须显式使用 mvn appengine:deployIndex
来生成索引。希望对其他人有帮助。
关于java - 未创建 GAE 数据存储索引,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41436403/