title: Is there any limit to the size of PUT/POST data while indexing documents in Elastic Search via Http call?
body: <p>I am creating a heavy-update search application using Elastic Search 5.0.1,  wherein hundreds of thousands of records are indexed into elastic search. This happens every few seconds for multiple indices from my Java client using <a href="https://docs.oracle.com/javase/7/docs/api/java/net/HttpURLConnection.html" rel="nofollow noreferrer">HttpURLConnection</a>. I am using <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-bulk.html" rel="nofollow noreferrer">elastic search's Bulk API</a> for which I create a single PUT entity containing line separated JSON strings like below (as shown in the <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-bulk.html" rel="nofollow noreferrer">Bulk API docs</a>):</p>
  
  <pre><code>action_and_meta_data\n
  optional_source\n
  action_and_meta_data\n
  optional_source\n
  ....
  action_and_meta_data\n
  optional_source\n
  </code></pre>
  
  <p>But, when the number of documents exceeds a certain limit, I get the following exception: </p>
  
  <pre><code>java.io.IOException: Error writing to server
      at sun.net.www.protocol.http.HttpURLConnection.writeRequests(HttpURLConnection.java:582)
      at sun.net.www.protocol.http.HttpURLConnection.writeRequests(HttpURLConnection.java:594)
      at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1216)
      at java.net.HttpURLConnection.getResponseCode(HttpURLConnection.java:379)
  </code></pre>
  
  <p>As I could check <a href="https://serverfault.com/questions/151090/is-there-a-maximum-size-for-content-of-an-http-post">here</a>, there is no theoretical limit to the PUT data size, but only the restrictions imposed by the client and server.</p>
  
  <p>Does Elastic Search service impose any such restrictions? If yes, what are those limits and how this case can be better handled (modify server limits or batch the queries)? </p>