Search code examples
javagoogle-app-enginejdo

Google App Engine Error: No matching index found. (Java)


I am writing a query but it always says "No matching index found". I don't know why. My code is as below:

Query query = pm.newQuery(Classified.class);
query.setFilter("emp_Id == emp");
query.setOrdering("upload_date desc");
query.declareParameters("String emp");
List<Classified> results = (List<Classified>)query.execute(session.getAttribute("emp_Id").toString()); 

<?xml version="1.0" encoding="utf-8"?>
<datastore-indexes autoGenerate="true">
  <datastore-index kind="Classified" ancestor="false">
    <property name="emp_Id" direction="asc" />
    <property name="category" direction="asc" />
    <property name="upload_date" direction="desc" />
  </datastore-index>
</datastore-indexes> 

I have added the above index, but it did not help.


Solution

  • I believe you need to configure a Datastore Index. There's probably one already generated for you in Eclipse at WEB-INF/appengine-generated/datastore-indexes-auto.xml that you just need to copy to WEB-INF/datastore-indexes.xml and deploy again.