Most efficient way to get all ids of a type

What's the best way in order to get all ids of a type using Java API?

Thanks.

Hi,

you can use the Scroll API together with a match_all query. But the better question is why you just need the ids.

Daniel

But it is good to remember that this isn't what Elasticsearch is good at - those _ids are stored with the _source so they can be slower to fetch. Elasticsearch's aggregations are fast because they use a column store (doc values). _id doesn't have that.

If performance is good enough for you then it is fine, but if it isn't then you are often better off thinking of reworking what you want to do as some kind of aggregation.