GAE中的多值属性查询

发布于 2024-10-07 06:35:58 字数 384 浏览 0 评论 0原文

类人{ @执着的 私有列表标签 = ArrayList() 我

想让用户根据他/她的标签查询一个人,所以我有这样的查询过滤器:

tags.contains(tagValue1)

,如果用户想要搜索多个标签,我只需添加到过滤器因此,如果用户正在搜索 3 个标签,则查询将为

tags.contains(tagValue1) && Tags.contains(tagValue2) && tag.contains(tagValue3)

我认为这种方法是错误的,因为数据存储区需要有一个包含 3 次标签属性的索引......如果用户一次搜索超过 3 个标签,那么它将被破坏。

执行此操作的正确方法是什么?你们有什么建议吗?

class Person{
@Persistent
private List tags = ArrayList()
}

I want to let the user query a person based on his/her tag, so I had my query filter like this:

tags.contains(tagValue1)

and if the user want to search for multiple tags, I would just add to the filter so if the user is searching for 3 tags, then the query would be

tags.contains(tagValue1) && tags.contains(tagValue2) && tags.contains(tagValue3)

I think this approach is wrong, because the datastore then needs to have an index that have the tags property three times... and if the user search for more than 3 tags at a time then it will be broken.

What's the proper way to do this? Do you guys have any suggestions?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

野味少女 2024-10-14 06:35:58

无法回答 GAE/J 插件如何处理的具体细节,但稍微更好的查询将是

tags.contains(theTag) && (theTag == tagValue1 || theTag == tagValue2 || theTag == tagValue3)

所以“theTag”是一个变量。

Can't answer on the specifics of how GAE/J's plugin processes that but a marginally better query would be

tags.contains(theTag) && (theTag == tagValue1 || theTag == tagValue2 || theTag == tagValue3)

so "theTag" is a variable.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文