getIndex() public méthode

Returns index client.
public getIndex ( ) : Index
Résultat Index Index object
Exemple #1
0
 /**
  * @param string|\Elastica\Type $type
  *
  * @return $this
  */
 public function setType($type)
 {
     if ($type instanceof Type) {
         $this->setIndex($type->getIndex()->getName());
         $type = $type->getName();
     }
     $this->_type = (string) $type;
     return $this;
 }
 /**
  * @param Type $type
  * @param int  $docs
  *
  * @return array
  */
 private function _addDocs(Type $type, $docs)
 {
     $insert = array();
     for ($i = 1; $i <= $docs; $i++) {
         $insert[] = new Document($i, array('_id' => $i, 'key' => 'value'));
     }
     $type->addDocuments($insert);
     $type->getIndex()->refresh();
     return $insert;
 }
 private function deleteWarmers($warmers)
 {
     foreach (array_keys($warmers) as $name) {
         $this->outputIndented("\tDeleting {$name}...");
         $name = urlencode($name);
         $path = "_warmer/{$name}";
         $this->pageType->getIndex()->request($path, 'DELETE');
         $this->output("done\n");
     }
     return Status::newGood();
 }
 protected function setUp()
 {
     $typeName = Cache::TYPE_NAME;
     $this->type = $this->prophesize('\\Elastica\\Type');
     $this->type->request(Argument::any(), Argument::cetera())->willReturn(true);
     $this->type->getName()->willReturn($typeName);
     $this->index = $this->prophesize('\\Elastica\\Index');
     $this->index->getType($typeName)->willReturn($this->type->reveal());
     $this->index->exists()->willReturn(true);
     $nsDoc = new Document('DoctrineNamespaceCacheKey[]', [Cache::VALUE_FIELD => serialize($this->namespaceId)]);
     $this->type->getIndex()->willReturn($this->index->reveal());
     $this->type->getDocument("DoctrineNamespaceCacheKey[]")->willReturn($nsDoc);
     $this->client = $this->prophesize('\\Elastica\\Client');
     $this->client->getIndex($this->indexName)->willReturn($this->index->reveal());
     $this->cache = new Cache($this->client->reveal(), ['index' => $this->indexName]);
 }
 /**
  * @param string|\Elastica\Type $type
  * @return \Elastica\Bulk\Action
  */
 public function setType($type)
 {
     if ($type instanceof Type) {
         $this->setIndex($type->getIndex()->getName());
         $type = $type->getName();
     }
     $this->_metadata['_type'] = $type;
     return $this;
 }
 /**
  *
  */
 public function refresh()
 {
     $this->type->getIndex()->refresh(true);
 }
Exemple #7
0
 /**
  * Construit les données afin que celles-ci soient indexées (avec les fields corrects)
  * Méthode non testée et non utilisée pour le moment (Préférable de la tester avant..)
  *
  * @param CMbObject     $datum the datum you want to construct
  * @param Elastica\Type $type  the type where you want to index the data
  *
  * @return array
  */
 function indexingDatum($datum, $type)
 {
     $datum_to_index = $this->constructDatum($datum);
     $document = $type->createDocument($datum['object_id'], $datum_to_index);
     switch ($datum['type']) {
         case 'create':
             $type->addDocument($document);
             break;
         case 'store':
             $type->updateDocument($document);
             break;
         case 'delete':
             $type->deleteDocument($document);
             break;
         case 'merge':
             //nothing to do
             /*supprimer un des deux et faire un update de l'autre.*/
             break;
         default:
             return false;
     }
     $type->getIndex()->refresh();
     $this->deleteDatumTemporaryTable($datum['search_indexing_id']);
     return true;
 }