Creating a Composite Index for AppEngine in a project based on Android-Studio

I used Android Studio to create both an Android project and its backend AppEngine Endpoints. I have a data warehouse for which I use Objectify. The system worked fine until I added a filter to my query (to show only specific email data).

Query<Report> query = ofy().load().type(Report.class).filter("email", user.getEmail()).order("email").order("-when").limit(limit);

This is the POJO Datastore Entity object:

@Entity
public class Report {
    @Id
    Long id;

    String who;

    @Index
    Date when;

    String what;

    @Index
    String email;
}

However, I get this error from the Google API Explorer when I try to test it:

com.google.appengine.api.datastore.DatastoreNeedIndexException: no matching index found.
The suggested index for this query is:
    <datastore-index kind=\"AccessReport\" ancestor=\"false\" source=\"manual\">
    <property name=\"email\" direction=\"asc\"/>
    <property name=\"when\" direction=\"desc\"/>
    </datastore-index>

As I understand it, I just need to create a composite index, including special email fields, and when they will be in a certain sort direction.

However, most of the documents that I find tell me to change datastore-indexes.xml.

App Engine . App Engine datastore-indexes.xml, //WEB-INF/appengine.

, .

- , Android Studio?

+4
1

datastore-indexes.xml /WEB-INF/. :

<datastore-indexes
  autoGenerate="true">

    <datastore-index kind=\"AccessReport\" ancestor=\"false\" source=\"manual\">
        <property name=\"email\" direction=\"asc\"/>
        <property name=\"when\" direction=\"desc\"/>
    </datastore-index>
</datastore-indexes>
+6

Source: https://habr.com/ru/post/1620916/


All Articles