简体   繁体   中英

How to get full explanation of Elasticsearch query Java?

I'm currecntly trying to test out some new score functions on my Elasticsearch query but I'm not yielding the results I am expecting.

I found this on their site about explaining queries here

I can run as a curl command but does anyone know how to translate this to use the Java api?

If you're using the ES5 Java API, you can get the explanation like this:

QueryBuilder query = matchAllQuery(); // your query

ExplainRequest request = new ExplainRequest("index", "type", "id").query(query);
ExplainResponse explainResponse = client.explain(request).actionGet();
Explanation explanation = explainResponse.getExplanation();

Where client is your org.elasticsearch.client.Client instance.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM