private void createSchema() {
// We will use the first customer data to infer types
Document firstCustomer = customersData.get(0);
// Customers schema
DocumentType customersType = DocumentType.createDocumentType("Customers",firstCustomer);
customersType.setReference("account",ElementType.TYPE_REFERENCE,"Accounts","number");
// Customer indices
customersType.addIndex("name",false);
customersType.addIndex("ssn",true);
customersType.addIndex("age",false);
connection.saveDocumentType(customersType);
// Accounts schema
Document firstAccount = (Document)firstCustomer.get("account");
DocumentType accountsType = DocumentType.createDocumentType("Accounts",firstAccount);
accountsType.setReference("owner",ElementType.TYPE_BACK_REFERENCE,"Customers","TODO");
// Accounts indices
accountsType.addIndex("owner",true);
accountsType.addIndex("number",true);
connection.saveDocumentType(accountsType);
}