GeezerVison is showing github.com — property has list_value and don't want to index will raise exception · Issue #398 · googleapis/google-cloud-python
property has list_value and don't want to index will raise exception #398Descriptionif a property is list_value and the property name is included in exclude_from_indexes
the following exception will raise.
The protobuf file has describe this behavior
// A list value.
// Cannot contain another list value.
// Cannot also have a meaning and indexing set.
repeated Value list_value = 7;
https://github.com/GoogleCloudPlatform/google-cloud-datastore/blob/v1beta2-rev1-2.1.0/proto/datastore_v1.proto#L123
File "/usr/local/lib/python2.7/dist-packages/gcloud/datastore/entity.py", line 244, in save
exclude_from_indexes=self.exclude_from_indexes())
File "/usr/local/lib/python2.7/dist-packages/gcloud/datastore/connection.py", line 425, in save_entity
result = self.commit(dataset_id, mutation)
File "/usr/local/lib/python2.7/dist-packages/gcloud/datastore/connection.py", line 329, in commit
datastore_pb.CommitResponse)
File "/usr/local/lib/python2.7/dist-packages/gcloud/datastore/connection.py", line 81, in _rpc
data=request_pb.SerializeToString())
File "/usr/local/lib/python2.7/dist-packages/gcloud/datastore/connection.py", line 59, in _request
raise Exception('Request failed. Error was: %s' % content)
Exception: Request failed. Error was: A Value containing a list_value cannot specify indexed.
An example
entity = Dataset(dataset, kind, exclude_from_indexes=('a',))
entity['a'] = [1,2,3]
entity.save()Activitydhermes commented on Dec 2, 2014 /cc @pcostell
The error message seems strange since a is excluded. Though maybe it is referring to the property in general.
Also I'm curious why lists can't be indexed. IIRC a query like
class Foo(ndb.Model):
bar = ndb.StringProperty(repeated=True)
q = Foo.query(Foo.bar == 10)
works just fine. pcostell commented on Dec 2, 2014 Unlike Cloud Datastore, the App Engine datastore just uses repeated values as opposed to a list_value. I believe each value of 'a' should specify if it can be indexed or not, for example:
{
key: ...
data: {
list_value {
value {
string_value: "hi",
indexed: False
},
value {
integer_value: 12,
indexed: False
}
}
}
}tseaver commented on Dec 3, 2014 The protobuf spec says that items in a list_values "[c]annot also have a meaning and indexing set." pcostell commented on Dec 3, 2014 I think the spec is actually saying that list_value cannot have a meaning and indexing set. The Value's inside can have indexing set. I'll be sure to tweak the protobuf spec to be more clear. tseaver commented on Dec 3, 2014 I bow to your knowledge of the backend. Note that having the items in the list declare their indexing directly seems completely counter-intuitive to me. dhermes commented on Dec 4, 2014 @pcostell ISTM we have a choice here to support a set of repeated values or a list_value. In our current implementation, the user doesn't select, we just imply list_value from the type of the value.
When and where would an end user decide if they wanted to use one or the other? pcostell commented on Dec 4, 2014 @dhermes -- In Cloud Datastore list_value is the only option. Putting an entity with the same property multiple times will result in an error. dhermes commented on Dec 30, 2014 @tseaver Did #399 fully fix this? ISTM it did, but want to double-check. tseaver commented on Dec 31, 2014
MetadataMetadataDevelopmentNo branches or pull requestsIssue actions
|