具有多个不等式的 App Engine NDB 查询? [英] App Engine NDB query with multiple inequalities?

查看:28
本文介绍了具有多个不等式的 App Engine NDB 查询?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

此处仅有的两个答案基本上涉及重构数据库以适应此限制,但我不确定在我的情况下如何做到这一点.

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.

例如:年龄<15,添加日期 > 15 天前,位置 == 圣克鲁斯等.可能需要大量的不等式过滤器.如何在 GAE 中实现这一目标?

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?

推荐答案

根据 文档(用于 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.

如果您在几个月后回来查看,这可能会改变.GAE 变化很快.

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.

这篇关于具有多个不等式的 App Engine NDB 查询?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆