Skip to content

Cannot combine 'order' and 'filters' in same query  #860

Description

@thesandlord

I am trying to query comments that belong to a story.

query=datastore.Query(kind='Comment', filters=[('storyid', '=', 12345)], order=['timestamp'])

This code breaks with to following error (I also have additional internal debug info I can share):

gcloud.exceptions.PreconditionFailed: 412nomatchingindexfound.

Trying to debug this, I found the following work with no problems:

Removing order

query=datastore.Query(kind='Comment', filters=[('storyid', '=', 12345)])

Removing filters

query=datastore.Query(kind='Comment', order=['timestamp'])

Changing order to use storyid

query=datastore.Query(kind='Comment', filters=[('storyid', '=', 12345)], order=['storyid'])

Why is this happening? The fact that the bottom three queries work and to top one does not is very confusing. Nothing I saw in the documentation indicates that filters and order affect each other.

Metadata

Metadata

Assignees

Labels

api: datastoreIssues related to the Datastore API.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions