Datastore indexes

111 views
Skip to first unread message

Lorenzo Bugiani

unread,
Oct 3, 2013, 9:43:45 AM10/3/13
to objectify...@googlegroups.com
What about datastore automatic index configuration?
Is this supported on objectify?

Jeff Schnitzer

unread,
Oct 3, 2013, 10:48:21 AM10/3/13
to objectify...@googlegroups.com
Yes, this is standard behavior of the GAE low-level API.

Jeff


On Thu, Oct 3, 2013 at 6:43 AM, Lorenzo Bugiani <canema...@gmail.com> wrote:
What about datastore automatic index configuration?
Is this supported on objectify?

--
You received this message because you are subscribed to the Google Groups "objectify-appengine" group.
To unsubscribe from this group and stop receiving emails from it, send an email to objectify-appen...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Lorenzo Bugiani

unread,
Oct 4, 2013, 5:22:50 AM10/4/13
to objectify...@googlegroups.com
Uhm wait... So I haven't understand a thing.

The App Engine documentation says that "With automatic index configuration enabled, the development server maintains a file named WEB-INF/appengine-generated/datastore-indexes-auto.xml in your app's war/ directory. When your app, running in the development server, attempts a datastore query for which there is no corresponding index in either datastore-indexes.xml or datastore-indexes-auto.xml, the server adds the appropriate configuration to datastore-indexes-auto.xml."

So it means that I haven't to configure manually my indexes, but I can leave the development server doing it for me, so I can do queries on all fields of my entities.

Instead, in "Query and Indexes" section of objectify, you say "Queries only return values in an index. If an entity field is not indexed, queries on that field will return no results."
So to perform a query on a field, I have to annotate that field with @Index before, and then I can do queries on It.

Is there something that I'm missing??


2013/10/3 Jeff Schnitzer <je...@infohazard.org>

Nicholas Okunew

unread,
Oct 4, 2013, 8:39:27 AM10/4/13
to objectify...@googlegroups.com
There are two types of indexes - single property indexes (which using objectify you use the @index annotation, or the low level API by specifying a property on an entity as indexed) and compound indexes - which are required to run a query across multiple fields or with a non-natural ordering. The two XML files are where you define the compound indexes. 

The low level API exposes and documents all of this. Objectify just exposes a more java friendly API. It might be helpful to read the full docs on using the low level API. This will give you a better understanding of how it works, and a greater appreciation of the heavy lifting objectify does for you.

Ken Bowen

unread,
Oct 4, 2013, 10:20:40 AM10/4/13
to objectify...@googlegroups.com
I believe the OP's problem here is that any GAE compound index requires that individual single (@index) indices be in place in order to function. Thus, if you have @index applied to all the individual fields that participate in the compound query you make, and if you issue that query under objectify in the dev server, the dev server will create a compound index for you in the xml files. But if you don't have all the single field indices in place before the query is issued, no compound will be created.
--Ken

On Oct 4, 2013, at 6:39 AM, Nicholas Okunew wrote:

Reply all
Reply to author
Forward
0 new messages