Add the datastore-indexes.xml file at war/WEB-INF folder
<?xml version="1.0" encoding="utf-8"?>
<datastore-indexes autoGenerate="true">
<datastore-index kind="Person" ancestor="false" source="manual">
<property name="lastName" direction="asc"/>
<property name="height" direction="asc"/>
</datastore-index>
</datastore-indexes>
import com.google.appengine.api.datastore.DatastoreService;
import com.google.appengine.api.datastore.DatastoreServiceFactory;
import com.google.appengine.api.datastore.Entity;
import com.google.appengine.api.datastore.PreparedQuery;
import com.google.appengine.api.datastore.Query;
import com.google.appengine.api.datastore.Query.FilterOperator;
........................
// Get the Datastore Service
DatastoreService datastore = DatastoreServiceFactory.getDatastoreService();
// The Query interface assembles a query
Query q = new Query("Person");
q.addFilter("lastName", Query.FilterOperator.EQUAL, "Mannir");
q.addFilter("height", FilterOperator.GREATER_THAN_OR_EQUAL, 16);
// PreparedQuery contains the methods for fetching query results
// from the datastore
PreparedQuery pq = datastore.prepare(q);
for(Entity result: pq.asIterable()){
String firstName = (String) result.getProperty("firstName");
String lastName = (String) result.getProperty("lastName");
Long height = (Long) result.getProperty("height");
resp.getWriter().println(lastName + " " + firstName + ", " + height.toString() + " inches tall");
}