移动后端启动器数据存储区查询多值属性

时间:2022-11-21 15:50:16

I've started implementing my own example with Mobile Backend Starter and cannot resolve one problem with queries. According to the spec https://developers.google.com/appengine/docs/java/datastore/queries there should be no difference making a query with filter for single or multi-valued property.

我已经开始使用Mobile Backend Starter实现我自己的示例,无法解决查询的一个问题。根据规范https://developers.google.com/appengine/docs/java/datastore/queries,使用过滤器查询单值或多值属性应该没有区别。

Unfortunately I can not make it work with an Android app example provided on Mobile Backend Starte page.

不幸的是,我无法使用Mobile Backend Starte页面上提供的Android应用程序示例。

Here is the code I use to add multi-valued property:

这是我用来添加多值属性的代码:

newPost.put("tags", Arrays.asList("one","two","three"));

and a filter I use to get each record containing one of the specified properties:

和我用来获取包含指定属性之一的每条记录的过滤器:

CloudQuery query = new CloudQuery("Guestbook");

query.setFilter(F.eq("tags","two"));

getCloudBackend().list(query, handler);

As a result an empty list is always returned. If no filter is specified, all properties are returned from the backend as expected.

因此,始终返回空列表。如果未指定过滤器,则会按预期从后端返回所有属性。

Is it possible to make queries for multi-valued properties with the current implementation?

是否可以使用当前实现查询多值属性?

2 个解决方案

#1


0  

Multi-valued properties can be queried. You can utilise a filter predicate

可以查询多值属性。您可以使用过滤谓词

Filter tagfilter = new FilterPredicate("tags",
                      FilterOperator.EQUAL,
                      "two");
query.setFilter(tagfilter);

#2


0  

The answer as far as I know about Mobile Backend Starter is no. Though I don't know about google-cloud-endpoints.

据我所知,Mobile Backend Starter的答案是否定的。虽然我不知道google-cloud-endpoints。

If I understand it right, you send a CloudEntity (newPost) with a property being a List. In the "documentation" of mobile backend starter they say that one of the supported types for CloudEntity are:

如果我理解正确,您发送一个CloudEntity(newPost),其属性为List。在移动后端启动程序的“文档”中,他们说CloudEntity支持的类型之一是:

List/Map:

列表/图:

java.util.List or java.util.Map object that can contain long strings (longer than 500 characters) and child List/Map. These elements are not indexed on Datastore and can not be used as a query filtering/sorting condition. Empty List/Maps are not stored on Datastore

java.util.List或java.util.Map对象,可以包含长字符串(长度超过500个字符)和子列表/映射。这些元素未在数据存储区中编制索引,因此无法用作查询过滤/排序条件。空列表/地图未存储在数据存储中

So you can not use that List/Map as a filter.

所以你不能使用List / Map作为过滤器。

#1


0  

Multi-valued properties can be queried. You can utilise a filter predicate

可以查询多值属性。您可以使用过滤谓词

Filter tagfilter = new FilterPredicate("tags",
                      FilterOperator.EQUAL,
                      "two");
query.setFilter(tagfilter);

#2


0  

The answer as far as I know about Mobile Backend Starter is no. Though I don't know about google-cloud-endpoints.

据我所知,Mobile Backend Starter的答案是否定的。虽然我不知道google-cloud-endpoints。

If I understand it right, you send a CloudEntity (newPost) with a property being a List. In the "documentation" of mobile backend starter they say that one of the supported types for CloudEntity are:

如果我理解正确,您发送一个CloudEntity(newPost),其属性为List。在移动后端启动程序的“文档”中,他们说CloudEntity支持的类型之一是:

List/Map:

列表/图:

java.util.List or java.util.Map object that can contain long strings (longer than 500 characters) and child List/Map. These elements are not indexed on Datastore and can not be used as a query filtering/sorting condition. Empty List/Maps are not stored on Datastore

java.util.List或java.util.Map对象,可以包含长字符串(长度超过500个字符)和子列表/映射。这些元素未在数据存储区中编制索引,因此无法用作查询过滤/排序条件。空列表/地图未存储在数据存储中

So you can not use that List/Map as a filter.

所以你不能使用List / Map作为过滤器。