class SearchDocument {

    String getProperty(String key) {
        if (key == null) {
            return "";
        }

        if (!key.contains(" ")) {
            // Get a single key
            Object value = document.get(key);

            if (value instanceof String) {
                return (String) value;
            } else {
                return "";
            }
        } else {
            // Build a name containing all keys
            StringBuilder builder = new StringBuilder("");
            String[] parts = key.split(" ");
            for (String part : parts) {
                builder.append(getProperty(part)).append(' ');
            }
            return builder.toString();
        }
    }

      SearchDocument(Map<String, Object> document);

}