0

I wish to get a list of Appointments from GAE under a specific Merchant and sort according the the date time it was made (dateLog):

PersistenceManager pm = PMF.get().getPersistenceManager();
String query = "select from " + Appointment.class.getName();  
query += " where merchant == '" + session.getAttribute("merchant") + "'";
query += " order by dateLog desc range 0,5";
List<Appointment> appointment = (List<Appointment>) pm.newQuery(query).execute(); 

However, it returns the error, and I have checked / double checked many times to no avail. Anyone can help? I'm stumped.

Taryn
  • 242,637
  • 56
  • 362
  • 405
Melvin
  • 105
  • 1
  • 2
  • 8

2 Answers2

0

You should specify the suggested index for datastore in WEB-INF/datastore-indexes.xml, in your app's war/ directory. The XML looks like this:

<?xml version="1.0" encoding="utf-8"?>
<datastore-indexes  autoGenerate="true">
  <datastore-index kind="Appointment" ancestor="false" source="manual">
    <property name="merchant" direction="asc"/> 
    <property name="dateLog" direction="desc"/> 
  </datastore-index>
</datastore-indexes>

Reference: https://developers.google.com/appengine/docs/java/config/indexconfig

Nijin Narayanan
  • 2,269
  • 2
  • 27
  • 46
  • Hi Nijin, thanks for getting back. A datestore-indexes.xml doesnt exist in my WEB-INF folder, and I created it with the above code it still doesnt work.. any idea? – Melvin Jun 25 '13 at 04:11
  • Are you redeployed your application ? After you redeployed with the new file in your application, do you now see the index in the "Indexes" section of the App Engine admin console? – Nijin Narayanan Jun 26 '13 at 03:59
0

If you test the URL before uploading to App engine server, then Index file will be auto generated. Run in development server and hit the URL which shows you the error, It will generate the File and when you deploy to App engine server, Indexes will be build and one more thing, It will take time you can see that in Datastore Indexes (Building and Serving) in the Google App Engine Admin Console.