# Difference between index/type/\_search and index/\_search results

**URL:** <https://discuss.elastic.co/t/difference-between-index-type--search-and-index--search-results/81314>\
**Category:** Elasticsearch\
**Created:** [April 5, 2017, 1:32pm UTC](https://discuss.elastic.co/t/difference-between-index-type--search-and-index--search-results/81314 "2017-04-05T13:32:23Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ramdev\_Wudali](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ramdev_wudali/32/7894_2.png) [@Ramdev\_Wudali](https://discuss.elastic.co/u/Ramdev_Wudali)\
**Post date:** [April 5, 2017, 1:32pm UTC](https://discuss.elastic.co/t/difference-between-index-type--search-and-index--search-results/81314/1 "2017-04-05T13:32:23Z")

</div>

Hi:  
I had asked this as a followup question, But I think it perhaps needs to be its own question :

If I have an Index - index and a single Type - type  
what is the difference between searching against endpoint

index/\_search AND  
index/type/\_search

Should the query against the two end points result in different ranking of documents (or even different documents. If it does result in different results, how does one explain the behavior.

This is on an index with 1 shard on a cluster of 3 nodes, running ES 2.3.3 with a Java 8 JVM

Thanks

Ramdev

---

<div class="post-metadata">

**Author:** ![nik9000](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/nik9000/32/44947_2.png) [@nik9000](https://discuss.elastic.co/u/nik9000)\
**Post date:** [April 5, 2017, 1:50pm UTC](https://discuss.elastic.co/t/difference-between-index-type--search-and-index--search-results/81314/2 "2017-04-05T13:50:11Z")

</div>

A search with a `type` in the URL adds an extra filter on that type. If you only have a single type in the index it should return documents scored the same way. If the scores are different and the documents aren't being modified I'd look at [`preference`](https://www.elastic.co/guide/en/elasticsearch/reference/current/search-request-preference.html). If that isn't it then I'm not sure off hand.

---

<div class="post-metadata">

**Author:** ![Ramdev\_Wudali](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ramdev_wudali/32/7894_2.png) [@Ramdev\_Wudali](https://discuss.elastic.co/u/Ramdev_Wudali)\
**Post date:** [April 5, 2017, 2:52pm UTC](https://discuss.elastic.co/t/difference-between-index-type--search-and-index--search-results/81314/3 "2017-04-05T14:52:08Z")

</div>

Hi @nik9000,

Thanks for that, After setting the preference to \_primary, I get the wrong result, but it does not change.

That said, the following is the problem I am facing :

I have an Index - index with a Type - type. (example)

when I search using the endpoint index/\_search , I get a set of results and every 3rd search gives the right result. The scores on the documents for the first 2 tries and the 3rd try are different. (Score for the first 2 tries for the top ranking document : 2.1197796, and the score for the 3rd try returning the correct document as the top ranking document : 2.2844782.

As far as I am concerned, that's a large difference in score. I would like to know why the difference.. The results are sort of deterministic in the sense that every 3rd try gives me the correct document. and the other two times, its the same wrong document with a lower score. When the correct document is not the top ranking document, it is returned with a score : 0.7614927

BUT, if the search endpoint is index/type/\_search, the correct document is returned with the same score (2.2844782) as above. and it never changes.

The number of documents returned are the same in both case.

---

<div class="post-metadata">

**Author:** ![nik9000](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/nik9000/32/44947_2.png) [@nik9000](https://discuss.elastic.co/u/nik9000)\
**Post date:** [April 5, 2017, 3:55pm UTC](https://discuss.elastic.co/t/difference-between-index-type--search-and-index--search-results/81314/4 "2017-04-05T15:55:08Z")

</div>

Weird. I don't know off hand, but here are the tools I usually use for this:

[https://www.elastic.co/guide/en/elasticsearch/reference/current/search-request-explain.html](https://www.elastic.co/guide/en/elasticsearch/reference/current/search-request-explain.html)  
[https://www.elastic.co/guide/en/elasticsearch/reference/current/search-explain.html](https://www.elastic.co/guide/en/elasticsearch/reference/current/search-explain.html)  
[https://www.elastic.co/guide/en/elasticsearch/reference/current/search-request-preference.html](https://www.elastic.co/guide/en/elasticsearch/reference/current/search-request-preference.html)  
[https://www.elastic.co/guide/en/elasticsearch/reference/current/cat-shards.html](https://www.elastic.co/guide/en/elasticsearch/reference/current/cat-shards.html)

The last one in particular needs some explanation - deleted documents effect score.

The explain API combined with preference should be able to tell you why the top ranking document is getting the weird score. I have no idea why adding the type to the search fixes it though.

---

<div class="post-metadata">

**Author:** ![Ramdev\_Wudali](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ramdev_wudali/32/7894_2.png) [@Ramdev\_Wudali](https://discuss.elastic.co/u/Ramdev_Wudali)\
**Post date:** [April 5, 2017, 5:09pm UTC](https://discuss.elastic.co/t/difference-between-index-type--search-and-index--search-results/81314/5 "2017-04-05T17:09:27Z")

</div>

Thanks @nik9000, here is what explain shows me :  
(two chunks...) :  
Correct document returned with explanation : (pay attention to document score).  
the explain sections shows the same score however, the document score is not what explain shows.  
(these are screen shots of the explain for correct\_document and wrong\_document).

 ![](https://us1.discourse-cdn.com/elastic/original/3X/2/7/2721e454b138b665f8bbb78f0d8b1c1e7c1c6a89.JPG) ![](https://us1.discourse-cdn.com/elastic/original/3X/8/1/81c2e984f14302a8906664571d2d8681b37955e9.JPG)

any insight ?

There is only 1 shard for the index and no replicas. on a 3 node ES cluster runnning ES2.3.3 on a Java 8 JVM.

---

<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:** [May 3, 2017, 5:09pm UTC](https://discuss.elastic.co/t/difference-between-index-type--search-and-index--search-results/81314/6 "2017-05-03T17:09:40Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
