public void index(final Entity entity, final Tenant tenant) throws SearchEngineException
{
try {
Map<String, Object> source = entityIndexDocumentPurveyor.purveyDocument(entity, tenant);
if (source.keySet().size() > 0) {
String entityName = StringUtils.substringAfterLast(entity.getClass().getName(), ".").toLowerCase();
this.logger.debug("Indexing {} with id {}...", entityName, entity.getId());
IndexRequestBuilder builder =
this.client.prepareIndex("entities", entityName, entity.getId().toString()).setSource(source);
if (tenant != null && !Tenant.class.isAssignableFrom(entity.getClass())) {
builder.setParent(tenant.getId().toString());
}
IndexResponse response = builder.execute().actionGet();
this.logger.debug("" + response.getType());
}
} catch (Exception e) {
throw new SearchEngineException("Failed to index entity", e);
}
}