예제 #1
0
 /**
  * @inheritdoc
  */
 public function insertObject(IndexInterface $index, $type, $object)
 {
     $transformer = $this->getTransformer($type);
     $mapping = $this->getIndexMapping($type);
     $document = $transformer->transform($object, $mapping);
     $document->setIndex($index->getName());
     $document->setType($type);
     return $this->insertDocument($document);
 }
예제 #2
0
 /**
  * @inheritdoc
  */
 public function deleteById(IndexInterface $index, $type, $ids, array $options = [])
 {
     $bulk = '';
     foreach ($ids as $id) {
         $bulk .= Json::encode(['delete' => ['_index' => $index->getName(), '_type' => $type, '_id' => $id]]) . "\n";
     }
     $url = [$index->getName(), $type, '_bulk'];
     $response = static::getDb()->post($url, [], $bulk);
     $responses = [];
     foreach ($response['items'] as $item) {
         $data = reset($item);
         $action = key($item);
         $responses[] = new Response($action, $data);
     }
     return new BulkResponse('delete', $response, $responses);
 }