title: Elasticsearch refreshing index automatically with index.refresh=-1?
body: <p>I am using Elasticsearch with the Java API. </p>
  
  <p>I am indexing offline data with big bulk inserts, so I set <code>index.refresh=-1</code> </p>
  
  <p>I don't refresh the index "manually" anywhere. </p>
  
  <p>It seems that refresh <em>is</em> done at some point, because queries do return data. The only scenario where the data wasn't returned was when I tested with just a few documents, and querying was done immediately after insertion (using the same <code>Client</code> object).</p>
  
  <p>I wonder if index refresh is called implicitly by Elasticsearch or by the Java library at some stage, even when <code>index.refresh=-1</code> ? </p>
  
  <p>Or how else could the behavior be explained? </p>
  
  <p>Client generation: </p>
  
  <pre><code>Client client = TransportClient.builder().settings(settings)
          .build()
          .addTransportAddress(new InetSocketTransportAddress(InetAddress.getByName(address),port));
  </code></pre>
  
  <p>Insertion: </p>
  
  <pre><code>BulkRequestBuilder bulkRequest = client.prepareBulk();
  
  for (MyObject object : list) {
      bulkRequest.add(client.prepareIndex(index, type)
              .setSource(XContentFactory.jsonBuilder()
                      .startObject()
                      // ... add object fields here ...
                      .endObject()
              ));
  }
  
  BulkResponse bulkResponse = bulkRequest.get();
  </code></pre>
  
  <p>Querying:</p>
  
  <pre><code>   QueryBuilder query = ...;
  
     SearchResponse resp = client.prepareSearch(index)
              .setQuery(query)
              .setSize(Integer.MAX_VALUE)
              // adding fields here 
              .get();
  
     SearchHit[] = resp.getHits().getHits();
  </code></pre>