Doco - Document Converter for Google App Engine Search API
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.


Doco (Document Converter) is a lightweight Java library used to convert (from and to) indexed Documents provided by Search API in Google App Engine.


How to Use Doco

Before converting objects to documents (or vice versa), you need to tell Doco which fields will be used. Maps the fields you want to search in a document with following annotations.



This annotation is applied to the entity class. This annotation defines the name of the IndexSpec. Doco by default assume the name of the class as index id

// the name of the index id will be "Foo"
public class Foo {}

You can set the index id as you want using the parameter name

@DocumentIndex(name = "customIndexId")
public class Foo {}


Place this annotation on fields of an entity POJO. This field defines the id of the document. The type of a field annotated with DocumentId must be Integer, Long or String.

private Long id;

You can specify a name to an id using name parameter

@DocumentId(name = "otherIdName")
private Long id;


Place this annotation on fields of an entity POJO. This annotation defines a field of a document. All fields must have a name and a type (see all types here). Doco assumes the same name of the annotated property to the name of the document field if the name was not specified, and assumes TEXT type by default.

private String textField;

Use de name property to specify a name to the field

@DocumentField(name = "otherName")
private String textField;

You can specify the field type using the type parameter

@DocumentField(type = FieldType.NUMBER)
private Double total;

Field Types:

These are all valid types you can use to specify a document field with a "type" parameter in a @DocumentField annotation.

Atom Field - an indivisible character string


Text Field - a plain text string that can be searched word by word


Number Field - an Integer, Double, Float or Long field


HTML Field - a string that contains HTML markup tags, only the text outside the markup tags can be searched


Date Field - a date object with year/month/day and optional time


Geopoint Field - a data object with latitude and longitude coordinates



Once you map your entity its time to play with Doco.

Converting a Foo object to a Document and putting it in a index
// just convert a Foo to a Document
Doco doco = new Doco();
Document document = doco.toDocument(foo);
// gets an Index and saves the Document
Index index = doco.getIndex(Foo.class);
Getting the Document in an index and converting it to a Foo object.
// gets the document from index
Doco doco = new Doco();
Index index = doco.getIndex(Foo.class);
Document document = index.get(12345L);

// simple way to convert a document to a Foo
Foo foo = doco.fromDocument(document, Foo.class);

See the [site] ( for more details


  • Java 1.5+
  • Google App Engine Java SDK 1.8.5+


  • Default type for: NUMBER, DATE and GEO_POINT
  • Convert collections

You can't do

  • A document with multiple fields with the same name
  • A NUMBER field value must be less than or equal to 2147483647.000000 (Google Search API limitation)

See Also

Search API documentation


Doco is released under the terms of the MIT License.