API error 4 (datastore_v3: NEED_INDEX): no matching index found

574 views
Skip to first unread message

stephanos

unread,
Jan 6, 2014, 1:54:27 PM1/6/14
to google-ap...@googlegroups.com
Hi everyone,

I'm executing a projection of an ancestor query (without any filters). There are no existing entities in the datastore. Locally it runs fine, but in production I get:

  API error 4 (datastore_v3: NEED_INDEX): no matching index found

Is this a bug?

Regards
Stephan

Glenn Lewis

unread,
Jan 6, 2014, 2:15:38 PM1/6/14
to stephanos, google-appengine-go
If you are performing an ancestor query, doesn't this imply that you know the ancestor and are using its index in the query?
uses "tomkey" as the ancestor.

If your datastore has no existing entities, then I'm guessing your ancestor does not yet exist in the datastore either, and therefore you get the error message.
Maybe it is not clear in the provided example that the "tomkey" ancestor already exists in the datastore.

Does that make sense?  If not, could you please share the code you are trying?
-- Glenn


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



--
Glenn Lewis | Software Engineer | gml...@google.com | 949-274-8923

David Symonds

unread,
Jan 6, 2014, 5:00:02 PM1/6/14
to stephanos, google-appengine-go
If you run dev_appserver.py with --require_indexes then I suspect
you'll get the same error locally.

Queries that require indexes still need those indexes when you have
zero entities.

stephanos

unread,
Jan 7, 2014, 10:57:22 AM1/7/14
to google-ap...@googlegroups.com, stephanos
Thanks, David and Glenn.
I added the require_indexes flag and now receive an error locally as well.

  ERROR: API error 4 (datastore_v3: NEED_INDEX): This query requires a composite index that is not defined. You must update the index.yaml file in your application root.

I've just looked at the documentation again and wonder what I have missed: I'm requesting the projection of an ancestor query. I thought only an index on each field is required for this.

Glenn Lewis

unread,
Jan 7, 2014, 12:47:16 PM1/7/14
to stephanos, google-appengine-go
Can you please share an example test case that exhibits the problem?
-- Glenn


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

David Symonds

unread,
Jan 7, 2014, 5:55:04 PM1/7/14
to stephanos, google-appengine-go
On 8 January 2014 02:57, stephanos <stephan...@gmail.com> wrote:

> I've just looked at the documentation again and wonder what I have missed:
> I'm requesting the projection of an ancestor query. I thought only an index
> on each field is required for this.

Nope: https://developers.google.com/appengine/docs/go/datastore/projectionqueries#Go_Indexes_for_projections

stephanos

unread,
Jan 8, 2014, 4:35:53 AM1/8/14
to google-ap...@googlegroups.com, stephanos
Oops, thank you. I better read those articles on datastore indexes again ...
Reply all
Reply to author
Forward
0 new messages