private void setIndex(String name, Object value, String key) {
        boolean isUnique = documentType.isUniqueIndex.get(name);
        Object oldKey = indexMap.get(value);
        if (oldKey == null) {
            if (isUnique) {
                indexMap.put(value,key);
            } else {
                ArrayList<String> values = new ArrayList<String>();
                values.add(key);
                indexMap.put(value,values);
            }
        } else {
            if (isUnique) {
                return;
                //throw new RuntimeException("Duplicate unique key entry");
            }
            ArrayList<String> values = (ArrayList<String>) oldKey;
            values.add(key);
        }
    }