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

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

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



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. If that isn't it then I'm not sure off hand.

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.

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


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.

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).

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.

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