Query-then-Fetch without sorting


#1

I see from here:

that a default query-then-fetch action will request the number of documents from each shard and then sort the results to give a final document set.

Does this happen also if no sort is specified? I'm assuming it does but just want to be sure.


#2

It looks as though a default score of 1 is used in the absence of any specified sort. From here:

https://www.elastic.co/guide/en/elasticsearch/guide/current/_sorting.html

The default sort order is _score descending. Filters have no bearing on _score, and the missing-but-implied match_all query just sets the _score to a neutral value of 1 for all documents. In other words, all documents are considered to be equally relevant.


(Martijn Van Groningen) #3

The default is the sort by score and if the query is not specified or the filter is used then the score is emitted is always 1. In sort sorting always happens.

If your don't care about ordering you can then sort by the internal Lucene id of a document. This is the efficient way of just fetching some docs via the _search api, especially in the ES 2.0 beta and up. If you want to sort by internal id, you should use the _doc as field to sort by.


(system) #4