---
title: "com.google.appengine.api.datastore.DatastoreNeedIndexException: no matching 解决方案"
author: "alloyer"
date: "2010-02-05T12:58:41Z"
tags: []
categories: ["编程语言"]
slug: "com-google-appengine-api-datastore-datastoreneedindexexception-no-matching"
draft: false
lastmod: "2010-02-09T01:48:51Z"
id: 588114
url: "https://alloyer.iteye.com/blog/588114"
---

Google App Engine查询时出现异常：

```java
com.google.appengine.api.datastore.DatastoreNeedIndexException: no matching index found..
```

解决方案：在项目的war/WEB-INF/目录中手动创建datastore-indexes.xml文件，在其中进行手动的索引配置，通常只要将以上异常中自动生成的提示索引拷贝到该文件中，然后重新部署项目即可。
索引的生效时间会稍微慢一些，可能需要几分钟时间。一个正常工作的索引的状态应该为Serving，见附件图示。

索引配置详见：
[http://code.google.com/intl/zh-CN/appengine/docs/java/config/indexconfig.html](http://code.google.com/intl/zh-CN/appengine/docs/java/config/indexconfig.html)
或[http://code.google.com/intl/zh-CN/appengine/docs/python/config/indexconfig.html](http://code.google.com/intl/zh-CN/appengine/docs/python/config/indexconfig.html)