# Get explain for all results returned for a query

**URL:** https://discuss.elastic.co/t/get-explain-for-all-results-returned-for-a-query/16828
**Category:** Elasticsearch
**Created:** [April 4, 2014, 9:28pm UTC](https://discuss.elastic.co/t/get-explain-for-all-results-returned-for-a-query/16828 "2014-04-04T21:28:56Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![Srinivasan\_Ramaswamy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/srinivasan_ramaswamy/32/74106_2.png) [@Srinivasan\_Ramaswamy](https://discuss.elastic.co/u/Srinivasan_Ramaswamy)
#### Post date: [April 4, 2014, 9:28pm UTC](https://discuss.elastic.co/t/get-explain-for-all-results-returned-for-a-query/16828/1 "2014-04-04T21:28:56Z")

</div>

Hi

I would like to get explain for top results that are returned for the  
query.

[http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/search-explain.html](http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/search-explain.html)

Shows me how to get explain for a query and a given document, but i want to  
explain for all (top 10 or 20 results, that i requested) the documents that  
are returned. Is there any parameter i can enable to get that information ?

Thanks  
Srini

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/28e409e6-b790-464b-a464-4aa65d70f3a5%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/28e409e6-b790-464b-a464-4aa65d70f3a5%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

### Author: ![Binh\_Ly\_2](https://avatars.discourse-cdn.com/v4/letter/b/d07c76/32.png) [@Binh\_Ly\_2](https://discuss.elastic.co/u/Binh_Ly_2)
#### Post date: [April 4, 2014, 10:20pm UTC](https://discuss.elastic.co/t/get-explain-for-all-results-returned-for-a-query/16828/2 "2014-04-04T22:20:16Z")

</div>

Yes, you can do:

curl localhost:9200/\_search -d '{  
"explain": true,  
"query": {}  
}'

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/6673d605-d13a-46b3-9307-380d0679a4f7%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/6673d605-d13a-46b3-9307-380d0679a4f7%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

### Author: ![Srinivasan\_Ramaswamy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/srinivasan_ramaswamy/32/74106_2.png) [@Srinivasan\_Ramaswamy](https://discuss.elastic.co/u/Srinivasan_Ramaswamy)
#### Post date: [April 4, 2014, 10:48pm UTC](https://discuss.elastic.co/t/get-explain-for-all-results-returned-for-a-query/16828/3 "2014-04-04T22:48:06Z")

</div>

When I try

{  
"query": {  
\* "explain": true,\*  
"function\_score": {  
"boost\_mode": "replace",  
"query": {  
"match": { "design.PRODUCT\_DESC":"cool"}  
},  
"filter": {  
"range": {  
"design.PRODUCT\_TYPE\_NO":{  
"from":1,  
"to":4  
}  
}  
},  
"script\_score": {  
"params": {  
"param1": 2,  
"param2": 3.1  
},  
"script": "\_score \* doc['design.CLICKS'].value / pow(param1,  
param2)"  
}  
}  
}  
}

I get the error message

Caused by: org.elasticsearch.index.query.QueryParsingException: [designs]  
[\_na] query malformed, no field after start\_object

at  
org.elasticsearch.index.query.QueryParseContext.parseInnerQuery(QueryParseContext.java:216)  
Without the explain line the above query works. What is the real syntax for  
explain along with function\_score ?

Thanks  
Srini

On Friday, April 4, 2014 3:20:16 PM UTC-7, Binh Ly wrote:

> Yes, you can do:
> 
> curl localhost:9200/\_search -d '{  
> "explain": true,  
> "query": {}  
> }'

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/e2017fdd-0e46-4925-a252-4876907b03a5%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/e2017fdd-0e46-4925-a252-4876907b03a5%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

### Author: ![Binh\_Ly\_2](https://avatars.discourse-cdn.com/v4/letter/b/d07c76/32.png) [@Binh\_Ly\_2](https://discuss.elastic.co/u/Binh_Ly_2)
#### Post date: [April 4, 2014, 10:58pm UTC](https://discuss.elastic.co/t/get-explain-for-all-results-returned-for-a-query/16828/4 "2014-04-04T22:58:17Z")

</div>

explain should be outside (same level) of query just like in my previous  
example. 🙂

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/5e1a3eef-5474-4cd9-b260-3c393069ed42%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/5e1a3eef-5474-4cd9-b260-3c393069ed42%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

### Author: ![Srinivasan\_Ramaswamy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/srinivasan_ramaswamy/32/74106_2.png) [@Srinivasan\_Ramaswamy](https://discuss.elastic.co/u/Srinivasan_Ramaswamy)
#### Post date: [April 4, 2014, 11:15pm UTC](https://discuss.elastic.co/t/get-explain-for-all-results-returned-for-a-query/16828/5 "2014-04-04T23:15:34Z")

</div>

Thanks for clearing it up for me. I was under the assumption that  
everything should be under the query, coz when i tried removing the outer  
query (earlier without the explain and just the function score) it didnt  
work.

Can you tell me what are the things that goes inside the query and what can  
go outside ? I am also confused coz there are two queries, one outside to  
wrap function\_score and one inside to represent the actual keyword.

Thanks  
Srini

On Friday, April 4, 2014 3:58:17 PM UTC-7, Binh Ly wrote:

> explain should be outside (same level) of query just like in my previous  
> example. 🙂

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/2cdd8cf4-f45c-465b-b91c-e5e495571580%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/2cdd8cf4-f45c-465b-b91c-e5e495571580%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

### Author: ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)
#### Post date: [July 6, 2017, 1:38am UTC](https://discuss.elastic.co/t/get-explain-for-all-results-returned-for-a-query/16828/6 "2017-07-06T01:38:02Z")

</div>


