title: Elastic Search : Got java.lang.IllegalArgumentException: The number of object passed must be even but was [1]
body: <p>ElasticSearch Version - 2.4.0</p>
  
  <p>Logs:</p>
  
  <pre><code>java.lang.IllegalArgumentException: The number of object passed must be even but was [1]
          at org.elasticsearch.action.index.IndexRequest.source(IndexRequest.java:451)
          at org.elasticsearch.action.index.IndexRequestBuilder.setSource(IndexRequestBuilder.java:186)
          at org.apache.kafka.connect.elasticsearchschema.ElasticsearchSinkTask.put(ElasticsearchSinkTask.java:138)
          at org.apache.kafka.connect.runtime.WorkerSinkTask.deliverMessages(WorkerSinkTask.java:381)
          at org.apache.kafka.connect.runtime.WorkerSinkTask.poll(WorkerSinkTask.java:227)
          at org.apache.kafka.connect.runtime.WorkerSinkTask.iteration(WorkerSinkTask.java:170)
          at org.apache.kafka.connect.runtime.WorkerSinkTask.execute(WorkerSinkTask.java:142)
          at org.apache.kafka.connect.runtime.WorkerTask.doRun(WorkerTask.java:140)
  </code></pre>
  
  <p>Code:</p>
  
  <pre><code>// This method will put the SinkRecords which are sent in bulk to Elastic Search with proper index and type. 
  public void put(Collection&lt;SinkRecord&gt; sinkRecords) {
      try {
        // Gets a list of SinkRecord from Kafka broker. 
        List&lt;SinkRecord&gt; records = new ArrayList&lt;SinkRecord&gt;(sinkRecords);
        for (int i = 0; i &lt; records.size(); i++) {
          BulkRequestBuilder bulkRequest = client.prepareBulk();
          // Looping through the SinkRecords and the size should be less than bulksize. 
          for (int j = 0; j &lt; bulkSize &amp;&amp; i &lt; records.size(); j++, i++) {
            SinkRecord record = records.get(i);
            // Index and type is hardcoded and record.value() contains the Json message.
            bulkRequest.add(client.prepareIndex("operative1", "test").setSource(record.value()));
          }
          i--;
          // Executing bulk requests.
          BulkResponse bulkResponse = bulkRequest.execute().actionGet();
         }
      } catch (Exception e) {
      }
    }
  </code></pre>
  
  <p>Input given is -> <code>{ "id1": "file", "value1": "File" }</code></p>
  
  <p>Please help to solve this.</p>