motoku motoku - 1 month ago 6
Java Question

Using 500+ Char Strings with Google AppEngine Datastore

I am trying to store a Document to the Google AppEngine Datastore. At first I tried using a Text object, but the stored text became truncated by some kind of indexing I was not able to find any information about. I now get the error: is not a supported property type.
How can I store a
longer than 500 characters?

This is the method to store the String:

public String post(String user, String documentText) {
if (!documents.hasProperty(user)) {
String indexesstr = (String) documents.getProperty(INDEXLABEL);
documents.setProperty(INDEXLABEL, indexesstr + "\n" + user);
documentText = documentText.replace("<", "&lt;");
documentText = documentText.replace("\n", "<br>");
documentText = documentText.replace("\r", "<br>");
Document doc = Document.newBuilder()
documents.setProperty(convertId(user), doc);

return makeIndex();

This is my method for retrieving the data:

public String getDocument(String contextPath) {
int offsSlash = contextPath.lastIndexOf("/") + 1;
String ID = contextPath.substring(offsSlash,
StringBuilder sb = new StringBuilder();
Document document = (Document) documents.getProperty(convertId(ID));
if (document == null)
sb.append("Document not found.");
else {
sb.append("<br><div align=\"right\">");
return sb.toString();


You need to use a Text value type. It's not truncated. This value type cannot be indexed.

See the list of supported value types for properties here:

Properties and value types

If you need to search inside a text string, you need to use the Search API. It has its own methods for inserting and retrieving documents - you cannot store a Document object in a property of a datastore entity.