use of org.elasticsearch.action.explain.ExplainRequestBuilder in project molgenis by molgenis.
the class ClientFacade method explain.
public Explanation explain(SearchHit searchHit, QueryBuilder query) {
if (LOG.isTraceEnabled()) {
LOG.trace("Explaining doc with id '{}' in index '{}' for query '{}' ...", searchHit.getId(), searchHit.getIndex(), query);
}
String indexName = searchHit.getIndex();
// FIXME: ClientFacade shouldn't assume that typename equals typename
ExplainRequestBuilder explainRequestBuilder = client.prepareExplain(indexName, indexName, searchHit.getId()).setQuery(query);
ExplainResponse explainResponse;
try {
explainResponse = explainRequestBuilder.get();
} catch (ElasticsearchException e) {
LOG.error("", e);
throw new IndexException(format("Error explaining doc with id '%s' in index '%s' for query '%s'.", searchHit.getId(), searchHit.getIndex(), query));
}
if (LOG.isDebugEnabled()) {
LOG.debug("Explained doc with id '{}' in index '{}' for query.", searchHit.getId(), searchHit.getIndex(), query);
}
return explainResponse.getExplanation();
}
Aggregations