# Problem with explain

**URL:** <https://discuss.elastic.co/t/problem-with-explain/14398>\
**Category:** Elasticsearch\
**Created:** [November 14, 2013, 4:54am UTC](https://discuss.elastic.co/t/problem-with-explain/14398 "2013-11-14T04:54:43Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![puyuan001](https://avatars.discourse-cdn.com/v4/letter/p/f04885/32.png) [@puyuan001](https://discuss.elastic.co/u/puyuan001)\
**Post date:** [November 14, 2013, 4:54am UTC](https://discuss.elastic.co/t/problem-with-explain/14398/1 "2013-11-14T04:54:43Z")

</div>

Hi all,  
I'm a newbie to es, and I've got a problem when using \_explain api,  
this is the command I use:

curl -XGET 'localhost:9200/question\_bank/questions/\_explain' -d '{  
"query" : {"query\_string" : {  
"query" : "a b c d"  
}}}'

and got this result:  
{"\_index":"question\_bank","\_type":"questions","\_id":"\_explain","exists":false}

Thanks so much for any help:)

--  
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).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![Ivan](https://avatars.discourse-cdn.com/v4/letter/i/df788c/32.png) [@Ivan](https://discuss.elastic.co/u/Ivan)\
**Post date:** [November 14, 2013, 6:25am UTC](https://discuss.elastic.co/t/problem-with-explain/14398/2 "2013-11-14T06:25:48Z")

</div>

The proper syntax is /{index}/{type}/{id}/\_explain

You need to add the id of the document to the API call.

[https://github.com/elasticsearch/elasticsearch/blob/master/src/main/java/org/elasticsearch/rest/action/explain/RestExplainAction.java?source=cc#L58-59](https://github.com/elasticsearch/elasticsearch/blob/master/src/main/java/org/elasticsearch/rest/action/explain/RestExplainAction.java?source=cc#L58-59)

--  
Ivan

On Wed, Nov 13, 2013 at 8:54 PM, [puyuan001@gmail.com](mailto:puyuan001@gmail.com) wrote:

> Hi all,  
> I'm a newbie to es, and I've got a problem when using \_explain api,  
> this is the command I use:
> 
> curl -XGET 'localhost:9200/question\_bank/questions/\_explain' -d '{  
> "query" : {"query\_string" : {  
> "query" : "a b c d"  
> }}}'
> 
> and got this result:
> 
> {"\_index":"question\_bank","\_type":"questions","\_id":"\_explain","exists":false}
> 
> Thanks so much for any help:)
> 
> --  
> 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).  
> For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

--  
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).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![puyuan001](https://avatars.discourse-cdn.com/v4/letter/p/f04885/32.png) [@puyuan001](https://discuss.elastic.co/u/puyuan001)\
**Post date:** [November 14, 2013, 8:10am UTC](https://discuss.elastic.co/t/problem-with-explain/14398/3 "2013-11-14T08:10:42Z")

</div>

thanks Ivan,  
after adding the id:  
curl -XGET 'localhost:9200/question\_bank/questions/0/\_explain' -d '{  
"query" : {"query\_string" : {  
"query" : "a b c d"  
}}}'

I got this:  
{"ok":false,"\_index":"question\_bank","\_type":"questions","\_id":"0","matched":false}

I also tried search with explain option, like this:  
curl -XGET 'localhost:9200/question\_bank/questions/\_search' -d '{  
"query" : {"query\_string" : {  
"query" : "a b c d"  
}},"explain":true}'

and I got:  
{"took":234,"timed\_out":false,"\_shards":{"total":2,"successful":2,"failed":0},"hits":{"total":1324189,"max\_score":13.550743,"hits":[{"\_shard":0,"\_node":"m-zznkETTn2Z5mSrCF4DzA","\_index":"question\_bank","\_type":"questions","\_id":"EEtIn8qkRKulaILawxLyVw","\_score":13.550743,  
"\_source" : {"id":3413350,"stem\_inner":" 设集合A={a，b}，B={b，c，d}，则A∪B=（ ）  
A、{b}B、{b，c，d}C、{a，c，d}D、{a，b，c，d}"},"\_explanation":{"value":0.0,"description":"product  
of:","details":[{"value":0.0,"description":"sum  
of:"},{"value":0.0,"description":"coord(0/4)"}]}},{"\_shard":0,"\_node":"m-zznkETTn2Z5mSrCF4DzA","\_index":"question\_bank","\_type":"questions","\_id":"Ua4UHbN\_R7C4rb3m57c4OQ","\_score":12.746416,  
"\_source" :  
{"id":2496941,"stem\_inner":"8.已知集合A={a，b}，B={a，b，c}，C={b，c，d}，那么集合(A∩B)∪C等于A{a，b，c}B{a，b，d}C{b，c，d}D{a，b，c，d}"},"\_explanation":{"value":0.0,"description":"product  
of:","details":[{"value":0.0,"description":"sum  
of:"},{"value":0.0,"description":"coord(0/4)"}]}},{"\_shard":0,"\_node":"m-zznkETTn2Z5mSrCF4DzA","\_index":"question\_bank","\_type":"questions","\_id":"YiqnTpRHTTKdmrMYsG0Lsg","\_score":12.746416,  
"\_source" : {"id":3410906,"stem\_inner":"  
已知集合A={a，b}，B={a，b，c}，C={b，c，d}，那么集合（A∩B）∪C等于（ ）  
A、{a，b，c}B、{a，b，d}C、{b，c，d}D、{a，b，c，d}"},"\_explanation":{"value":0.0,"description":"product  
of:","details":[{"value":0.0,"description":"sum  
of:"},{"value":0.0,"description":"coord(0/4)"}]}},{"\_shard":0,"\_node":"m-zznkETTn2Z5mSrCF4DzA","\_index":"question\_bank","\_type":"questions","\_id":"TIdSFa8hQ0-wkgOZZA7reA","\_score":12.324519,  
"\_source" : {"id":348640,"stem\_inner":"设集合A={a，b}，B={b，c，d}，则A∪B= [  
]A．{b} B．{b，c，d} C．{a，c，d} D．{a，b，c，d}  
"},"\_explanation":{"value":0.0,"description":"product  
of:","details":[{"value":0.0,"description":"sum  
of:"},{"value":0.0,"description":"coord(0/4)"}]}},{"\_shard":1,"\_node":"4ZIK6-O-SvyD4BSNYrZL0g","\_index":"question\_bank","\_type":"questions","\_id":"BMlUOGJ9T1egOdR2IgpOOA","\_score":12.191338,  
"\_source" : {"id":326247,"stem\_inner":"设，，，则[]A、a＜b＜c B、c＜b＜a C、c＜a＜b  
D、b＜a＜c "},"\_explanation":{"value":0.0,"description":"product  
of:","details":[{"value":0.0,"description":"sum  
of:"},{"value":0.0,"description":"coord(0/4)"}]}},{"\_shard":0,"\_node":"m-zznkETTn2Z5mSrCF4DzA","\_index":"question\_bank","\_type":"questions","\_id":"tZyT7YLXQNS3b8CT9cqm\_A","\_score":12.18048,  
"\_source" : {"id":484715,"stem\_inner":"设，，，则[]A、a＜b＜c B、c＜b＜a C、c＜a＜b  
D、b＜a＜c "},"\_explanation":{"value":0.0,"description":"product  
of:","details":[{"value":0.0,"description":"sum  
of:"},{"value":0.0,"description":"coord(0/4)"}]}},{"\_shard":0,"\_node":"m-zznkETTn2Z5mSrCF4DzA","\_index":"question\_bank","\_type":"questions","\_id":"5ReZjgkDR4y6pEirHwLQsQ","\_score":12.18048,  
"\_source" : {"id":486184,"stem\_inner":"若，则 []A、a＜b＜c B、c＜b＜a C、c＜a＜b  
D、b＜a＜c "},"\_explanation":{"value":0.0,"description":"product  
of:","details":[{"value":0.0,"description":"sum  
of:"},{"value":0.0,"description":"coord(0/4)"}]}},{"\_shard":1,"\_node":"4ZIK6-O-SvyD4BSNYrZL0g","\_index":"question\_bank","\_type":"questions","\_id":"fWcTQJelRpqHOKeDiwITDg","\_score":12.084454,  
"\_source" : {"id":321858,"stem\_inner":"若a=-0.42，b=-4-2，c=，则a、b、c、d的大小关系为[  
]A、a＜b＜c＜d B、b＜a＜d＜c C、a＜d＜c＜b D、c＜a＜d＜b  
"},"\_explanation":{"value":0.0,"description":"product  
of:","details":[{"value":0.0,"description":"sum  
of:"},{"value":0.0,"description":"coord(0/4)"}]}},{"\_shard":1,"\_node":"4ZIK6-O-SvyD4BSNYrZL0g","\_index":"question\_bank","\_type":"questions","\_id":"u5egHX5FRVKPfeWHzNduxQ","\_score":11.856148,  
"\_source" : {"id":3522849,"stem\_inner":"图中A,B,C,D四地，属于背斜构造的是（ ）A、A  
B、B C、C  
D、D"},"\_explanation":{"value":0.0,"description":"product  
of:","details":[{"value":0.0,"description":"sum  
of:"},{"value":0.0,"description":"coord(0/4)"}]}},{"\_shard":0,"\_node":"m-zznkETTn2Z5mSrCF4DzA","\_index":"question\_bank","\_type":"questions","\_id":"Gqj4krlpSfyG2T2Jqw1R7A","\_score":11.841712,  
"\_source" :  
{"id":2691009,"stem\_inner":"已知集合A={a，b}，B={a，b，c}，C={b，c，d}，那么集合（A∩B）∪C等于（  
）A．{a，b，c}B．{a，b，d}C．{b，c，d}D．{a，b，c，d}"},"\_explanation":{"value":0.0,"description":"product  
of:","details":[{"value":0.0,"description":"sum  
of:"},{"value":0.0,"description":"coord(0/4)"}]}}]}}

在 2013年11月14日星期四UTC+8下午2时25分48秒，Ivan Brusic写道：

> The proper syntax is /{index}/{type}/{id}/\_explain
> 
> You need to add the id of the document to the API call.
> 
> [https://github.com/elasticsearch/elasticsearch/blob/master/src/main/java/org/elasticsearch/rest/action/explain/RestExplainAction.java?source=cc#L58-59](https://github.com/elasticsearch/elasticsearch/blob/master/src/main/java/org/elasticsearch/rest/action/explain/RestExplainAction.java?source=cc#L58-59)
> 
> --  
> Ivan
> 
> On Wed, Nov 13, 2013 at 8:54 PM, \<[puyu...@gmail.com](mailto:puyu...@gmail.com) \<javascript:\>\> wrote:
> 
> > Hi all,  
> > I'm a newbie to es, and I've got a problem when using \_explain api,  
> > this is the command I use:
> > 
> > curl -XGET 'localhost:9200/question\_bank/questions/\_explain' -d '{  
> > "query" : {"query\_string" : {  
> > "query" : "a b c d"  
> > }}}'
> > 
> > and got this result:
> > 
> > {"\_index":"question\_bank","\_type":"questions","\_id":"\_explain","exists":false}
> > 
> > Thanks so much for any help:)
> > 
> > --  
> > 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 [elasticsearc...@googlegroups.com](mailto:elasticsearc...@googlegroups.com) \<javascript:\>.  
> > For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

--  
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).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<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, 2:07am UTC](https://discuss.elastic.co/t/problem-with-explain/14398/4 "2017-07-06T02:07:16Z")

</div>


