Hello,
I'm using the new google-cloud-datastore 0.3.0
I'm trying to write a json object into the datastore, this object can be larger than 1500 bytes.
This is my code:
Entity entity = Entity.builder(syncKey)
.set("id", objId)
.set("json_obj", Blob.copyFrom(objJson.toString().getBytes()))
.set("status", "on_progress")
.set("type", syncLocation)
.set("started_at", DateTime.now())
.build();
datastore.put(entity);
And I'm getting this exception:
"Code: 3 Message: The value of property "json_obj" is longer than 1500 bytes. - com.google.cloud.datastore.DatastoreException: The value of property "json_obj" is longer than 1500 bytes.
I thought the blob object didn't have a 1500 bytes restriction.
Is it possible to specify with the API that this property should not be indexed?
Hi @ghorkov, thanks for the report!
Is it possible to specify with the API that this property should not be indexed?
Sure, you should be able to do that with:
Blob blob = Blob.copyFrom(objJson.toString().getBytes());
Entity entity = Entity.builder(key)
.set("id", objId)
.set("json_obj", BlobValue.builder(blob).excludeFromIndexes(true).build())
.set("status", "on_progress")
.set("type", syncLocation)
.set("started_at", DateTime.now())
.build();
datastore.put(entity);
Please let us know if this fixes your problem.
Thank you @mziccard it worked like magic :)
I am using API 2.0.0, what did you mean by Entity in here? How do i get its instance? Any recent resource on it?
Most helpful comment
Hi @ghorkov, thanks for the report!
Sure, you should be able to do that with:
Please let us know if this fixes your problem.