org.elasticsearch.action.explain.ExplainRequestBuilder Java Examples

The following examples show how to use org.elasticsearch.action.explain.ExplainRequestBuilder. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ClientFacade.java    From molgenis with GNU Lesser General Public License v3.0 5 votes vote down vote up
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();
}
 
Example #2
Source File: AbstractClient.java    From Elasticsearch with Apache License 2.0 4 votes vote down vote up
@Override
public ExplainRequestBuilder prepareExplain(String index, String type, String id) {
    return new ExplainRequestBuilder(this, ExplainAction.INSTANCE, index, type, id);
}
 
Example #3
Source File: ClientWithStats.java    From rdf4j with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
@Override
public ExplainRequestBuilder prepareExplain(String index, String type, String id) {
	return wrapped.prepareExplain(index, type, id);
}
 
Example #4
Source File: FessEsClient.java    From fess with Apache License 2.0 4 votes vote down vote up
@Override
public ExplainRequestBuilder prepareExplain(final String index, final String type, final String id) {
    return client.prepareExplain(index, type, id);
}
 
Example #5
Source File: Client.java    From Elasticsearch with Apache License 2.0 2 votes vote down vote up
/**
 * Computes a score explanation for the specified request.
 *
 * @param index The index this explain is targeted for
 * @param type  The type this explain is targeted for
 * @param id    The document identifier this explain is targeted for
 */
ExplainRequestBuilder prepareExplain(String index, String type, String id);