title: Indexing in elasticsearch example?
body: <p>I read <a href="https://www.elastic.co/guide/en/elasticsearch/client/php-api/current/_indexing_operations.html#_bulk_indexing" rel="nofollow">tutorial</a> about indexing documents in Elasticsearch.
  There is example with bulk indexing. I have question, is it correct when is created array with two key for one item in the loop:</p>
  
  <pre><code>for($i = 0; $i &lt; 100; $i++) {
      $params['body'][] = array(
          'index' =&gt; array(
              '_id' =&gt; $i
          )
      );
  
      $params['body'][] = array(
          'my_field' =&gt; 'my_value',
          'second_field' =&gt; 'some more values'
      );
  }
  </code></pre>
  
  <p>Why there are two initizalizations of array <code>$params['body'][]</code> in loop?
  Must be index setting by the same key like as <code>my_field</code>?</p>
  
  <p>I mean one case, when all information about index is added in array by one key(index):</p>
  
  <pre><code>$params['body'][] = array(
              'index' =&gt; array(
                  '_id' =&gt; $i
              ),
  
              'my_field' =&gt; 'my_value',
              'second_field' =&gt; 'some more values'
          );
  </code></pre>
  
  <p>Also after search query I get error:</p>
  
  <blockquote>
    <p>Message: Illegal string offset 'match' on line where is:</p>
  </blockquote>
  
  <pre><code>$query['match']['name'] = $query;
  </code></pre>
  
  <p>where <code>$query</code> is string.</p>
  
  <p>I suppose that this error with problem in creation of index, therefore I have begun with this.</p>
  
  <p>My code which adds document in index:</p>
  
  <pre><code>private function addDocument($data = array(), $type)
      {
          if (!empty($data)) {
              foreach ($data as $key =&gt; $val) {
                  $params['body'][] = array(
                      'index' =&gt; array(
                          '_id' =&gt; $key,
                          '_type' =&gt; 'profiles',
                          '_index' =&gt; $this-&gt;_typeIndex($type)
                      )
                  );
  
                  $params['body'][] = (array)$val;
              }
  
              $this-&gt;client-&gt;bulk($params);
          }
  
      }
  </code></pre>
  
  <p>Is it right? Because in search I get error, that described here</p>