/**
  * {@inheritdoc}
  */
 public function store(array $data, array $keys, $namespace)
 {
     $type = $this->index->getType($namespace);
     // Build mapping
     $mapping = new Mapping();
     $mapping->setType($type);
     $mapping->setProperties(array('hash' => array('type' => 'string', 'include_in_all' => true), 'keys' => array('type' => 'string', 'include_in_all' => true)));
     $mapping->send();
     // Build document
     $document = new Document('', array_merge($data, array('hash' => $this->getHash($data, $keys), 'keys' => $keys)));
     $type->addDocument($document);
     $this->index->refresh();
 }
Пример #2
0
 /**
  * Creates a new Type object
  *
  * @param Elastica\Index $index the Index where you want to create your Type
  * @param string         $name  Type name
  *
  * @return Elastica\Type
  */
 function createType($index, $name)
 {
     return $index->getType($name);
 }