问题
The only two answers on here involve essentially restructuring the database to accommodate this limitation, but I am unsure how to do that in my case.
I have a list of thousands of contacts, each with many many properties. I'm making a page that has an ability to filter on multiple properties at once.
For example: Age < 15, Date Added > 15 days ago, Location == Santa Cruz, etc. Potentially a ton of inequality filters required. How does one achieve this in GAE?
回答1:
According to the docs (for python),
Limitations: The Datastore enforces some restrictions on queries. Violating these will cause it to raise exceptions. For example, combining too many filters, using inequalities for multiple properties, or combining an inequality with a sort order on a different property are all currently disallowed. Also filters referencing multiple properties sometimes require secondary indexes to be configured.
If you check back in a few months, this may change. GAE keeps changing pretty quickly.
For now, though, you'll have to make multiple queries and combine them in your code.
来源:https://stackoverflow.com/questions/16114762/app-engine-ndb-query-with-multiple-inequalities