Can't store entities with embedded entities which have properties > 1500 bytes
See original GitHub issueSeems that excluding a top level property doesn’t exclude an embedded entities properties from being indexed - on top of that, I don’t believe there’s a way to exclude an embedded entities individual properties, that would solve my problem too.
Steps to reproduce
Just use this script (I’m running the datastore emulator)
const Datastore = require('@google-cloud/datastore');
const datastore = new Datastore({ projectId: 'datastore-test' });
datastore.insert({
key: datastore.key('User'),
data: [
{
name: 'description',
value: {
text: Buffer.alloc(1501, 'a').toString(),
},
excludeFromIndexes: true
}
]
}, (err, result) => {
if (err) {
console.error(err);
} else {
console.log(result.data);
}
});
I’d expect there to be no error - the embedded entity ({ text: '...' }
) shouldn’t be indexed I believe? But it throw an error saying:
Error: The value of property "text" is longer than 1500 bytes.
Environment
- OS: OS X Sierra
- Node.js: v6.7.0
- npm: 3.10.3
- @google-cloud/datastore: v0.6.0
Issue Analytics
- State:
- Created 7 years ago
- Reactions:4
- Comments:41 (18 by maintainers)
Top Results From Across the Web
Google Datastore 1500 byte property limit for embedded entities
I am trying to write an embedded entity that has some properties that are longer than 1500 bytes and I'm getting an error:....
Read more >Entities, Properties, and Keys | Cloud Datastore Documentation
Data objects in Firestore in Datastore mode are known as entities. An entity has one or more named properties, each of which can...
Read more >Model and Property — ndb documentation - Google Cloud
A model class represents the structure of entities stored in the datastore. ... property is indexed but the value exceeds the maximum length...
Read more >Hibernate Search 6.0.10.Final: Migration Guide from 5.11
If you need both a Lucene backend and an Elasticsearch backend, proceed as follows: Annotate entities that must be indexed in the ...
Read more >datastore package - github.com/derivita/fsdatastore - Go Packages
The Get and Put functions load and save an entity's contents. ... than 1500 bytes cannot be indexed; fields used to store long...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Could I ask what the status of this issue is? I have some entities that have embedded entities that have properties that are >1500 Bytes. When I try setting
excludeFromIndexes: true
on the embedded entity I still get an error thrown for its sub-properties that are >1500 Bytes. Is there some way I can store them?@stephenplusplus thanks for the options - I think the
data
seems to make the more sense to me… i.e.value
is for more ‘basic’ types, anddata
for embedded objects.It’s pretty fringe edge case at this point - and I’m not sure if it’s even possible to do, but if you had an array of objects, could you index them?
e.g.
Other than that, I can’t see any issue with them…Another option would be making an
datastore.value
style factory - likedatastore.key
- where you can specify types and the data associated with it e.g.Ha - after writing that all out, I realise how incredibly over the top that looks, but it feels robust. Perhaps not as a candidate for quickly writing out simple entities, but perhaps as a way that will work well with a helper utility? e.g. for my use case, I’m converting incoming JSON to an entity, and I want to recursively step through it and add
excludeFromIndexes
as needed…thoughts?