function it_checks_if_a_document_already_exists(\Pocketphp_Elasticsearch_Model_Interface_Indexer_Type $indexer)
 {
     $indexer->getIndexName()->willReturn('products');
     $indexer->getIndexType()->willReturn('product');
     $this->documentExists($indexer, 1, 27)->shouldReturn(true);
 }
 /**
  * @param Pocketphp_Elasticsearch_Model_Interface_Indexer_Type $indexer
  * @param                                                      $store
  * @param                                                      $id
  * @param array                                                $data
  * @return array
  */
 public function indexDocument(Pocketphp_Elasticsearch_Model_Interface_Indexer_Type $indexer, $store, $id, array $data)
 {
     $params = array();
     $params['index'] = $indexer->getIndexName() . "_{$store}";
     $params['type'] = $indexer->getIndexType();
     $params['id'] = $id;
     $params['body'] = $data;
     if ($this->documentExists($indexer, $store, $id)) {
         $params['body'] = array();
         $params['body']['doc'] = $data;
         return $this->getClient()->update($params);
     }
     return $this->getClient()->index($params);
 }