BadValueError: Indexed value message_text must be at most 1500 bytes
BadValueError: Indexed value message_text must be at most 1500 bytes
我将 HTML 存储在实体的属性中。我现在面临的问题是 HTML 的大小可以大于 1500 字节。我是否在突破 Google Cloud Datastore 的界限?
我在模型中使用 TextProperty
class Article(ndb.Model):
title = ndb.StringProperty()
author = ndb.StringProperty()
content = ndb.TextProperty()
date_created = ndb.DateTimeProperty(auto_now_add=True)
date_modified = ndb.DateTimeProperty(auto_now=True)
问题 1
我应该考虑将 html 存储在 Google 云存储还是其他一些选项中?
问题二
是否可以增加给定实体的索引值的大小?
您对大于 1500 字节的字符串值使用 TextProperty 是正确的,但是 TextProperty 无法被索引,这就是您的问题。
class TextProperty()
A long string.
Unlike StringProperty, a TextProperty value can be more than 1500
bytes long. However, TextProperty values are not indexed and cannot be
used in filters or sort orders.
TextProperty values store text with a text encoding. For binary data,
use BlobProperty.
If the text property is required, its value cannot be an empty string.
Is it possible to increase the size of the indexed value of a given entity ?
没有。可以索引短字符串 因为 它们很短。
Should I look at storing html in Google Cloud Storage or some other options ?
如果只有1个html,建议写到文件中
如果不是真的需要,您当然也可以不索引 TextProperty。
我将 HTML 存储在实体的属性中。我现在面临的问题是 HTML 的大小可以大于 1500 字节。我是否在突破 Google Cloud Datastore 的界限?
我在模型中使用 TextProperty
class Article(ndb.Model):
title = ndb.StringProperty()
author = ndb.StringProperty()
content = ndb.TextProperty()
date_created = ndb.DateTimeProperty(auto_now_add=True)
date_modified = ndb.DateTimeProperty(auto_now=True)
问题 1
我应该考虑将 html 存储在 Google 云存储还是其他一些选项中?
问题二
是否可以增加给定实体的索引值的大小?
您对大于 1500 字节的字符串值使用 TextProperty 是正确的,但是 TextProperty 无法被索引,这就是您的问题。
class TextProperty()
A long string.
Unlike StringProperty, a TextProperty value can be more than 1500 bytes long. However, TextProperty values are not indexed and cannot be used in filters or sort orders.
TextProperty values store text with a text encoding. For binary data, use BlobProperty.
If the text property is required, its value cannot be an empty string.
Is it possible to increase the size of the indexed value of a given entity ?
没有。可以索引短字符串 因为 它们很短。
Should I look at storing html in Google Cloud Storage or some other options ?
如果只有1个html,建议写到文件中
如果不是真的需要,您当然也可以不索引 TextProperty。