Problem Regarding DataStore indexes

46 views
Skip to first unread message

Deepesh Mathuria

unread,
Apr 18, 2016, 6:07:54 AM4/18/16
to Google App Engine
I've used JPA to persist the data into GAE Datastore and I've annotated the fields to be indexed in my Entity classes with @Index but when deployed, the DataStore auto Indexeing does not index all the fields which I annotated and therefore when I query it results into DataStoreIndexNotFoundException.
Suggest the ways to rectify this

Nicholas (Google Cloud Support)

unread,
Apr 18, 2016, 11:30:11 AM4/18/16
to Google App Engine
Thanks for posting your questions here regarding JPA @Index support. Though it's not explicitly stated in the documentation as an unsupported feature of JPA, it is not mentioned anywhere or given as an example. Given that JPA was designed primarily with traditional relational databases in mind, I don't expect this feature to be integrated. The documentation above has labeled JPA as a superseded storage solution while advising users to use the lower-level Datastore API directly or a library built for Datastore like Objectify.

If you do not intend to migrate over to such a library, you could instead take advantage of datastore-indexes.xml to configure your indexes as recommended in this Index configuration article. An example can be found here detailing how this XML file should be structured to be used by App Engine.

Note that one could also use the development server to generate an index configuration file. Rather than throwing exceptions, the development server will generate indexes when attempting a query that requires one. This can be very useful if your development tests include all the query possibilities you might encounter.

I hope this helps!
Reply all
Reply to author
Forward
0 new messages