final ExchangeSearchResult result = master.search(request);
if (result.getFirstDocument() != null) {
//System.out.println("Updating " + exchange.getName());
final ExchangeDocument document = result.getFirstDocument();
document.setExchange(exchange);
master.update(document);
} else {
//System.out.println("Adding " + exchange.getName());
master.add(new ExchangeDocument(exchange));
}
}