title: Elasticsearch Java API - How to get the number of documents without retrieving the documents
body: <p>I need to get the number of documents in an index. not the documents themselves, but just this "how many" .</p>
  
  <p>What's the best way to do that?</p>
  
  <p>There is <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/search-count.html" rel="nofollow noreferrer">https://www.elastic.co/guide/en/elasticsearch/reference/current/search-count.html</a>. but I'm looking to do this in Java. </p>
  
  <p>There also is <a href="https://www.elastic.co/guide/en/elasticsearch/client/java-api/2.4/count.html" rel="nofollow noreferrer">https://www.elastic.co/guide/en/elasticsearch/client/java-api/2.4/count.html</a>, but it seems way old. </p>
  
  <p>I can get all the documents in the given index and come up with "how many". But there must be a better way.</p>