/**
  * Builds a Mapping collection from the annotation sources that are present
  *
  * @throws \Flowpack\ElasticSearch\Exception
  * @return \Flowpack\ElasticSearch\Mapping\MappingCollection<\Flowpack\ElasticSearch\Domain\Model\Mapping>
  */
 public function buildMappingInformation()
 {
     if (!$this->client instanceof Model\Client) {
         throw new \Flowpack\ElasticSearch\Exception('No client was given for mapping retrieval. Set a client BackendMappingBuilder->setClient().', 1339678111);
     }
     $this->indicesWithoutTypeInformation = array();
     $response = $this->client->request('GET', '/_mapping');
     $mappingInformation = new MappingCollection(MappingCollection::TYPE_BACKEND);
     $mappingInformation->setClient($this->client);
     $indexNames = $this->indexInformer->getAllIndexNames();
     foreach ($response->getTreatedContent() as $indexName => $indexSettings) {
         if (!in_array($indexName, $indexNames)) {
             continue;
         }
         $index = new Model\Index($indexName);
         if (empty($indexSettings)) {
             $this->indicesWithoutTypeInformation[] = $indexName;
         }
         foreach ($indexSettings as $typeName => $typeSettings) {
             $type = new Model\GenericType($index, $typeName);
             $mapping = new Model\Mapping($type);
             if (isset($typeSettings['properties'])) {
                 foreach ($typeSettings['properties'] as $propertyName => $propertySettings) {
                     foreach ($propertySettings as $key => $value) {
                         $mapping->setPropertyByPath(array($propertyName, $key), $value);
                     }
                 }
             }
             $mappingInformation->add($mapping);
         }
     }
     return $mappingInformation;
 }
 /**
  * @param string $method
  * @param \Flowpack\ElasticSearch\Domain\Model\Client $client
  * @param string $path
  * @param array $arguments
  * @param string|array $content
  *
  * @return \Flowpack\ElasticSearch\Transfer\Response
  */
 public function request($method, \Flowpack\ElasticSearch\Domain\Model\Client $client, $path = null, $arguments = array(), $content = null)
 {
     $clientConfigurations = $client->getClientConfigurations();
     $clientConfiguration = $clientConfigurations[0];
     $uri = clone $clientConfiguration->getUri();
     if ($path !== null) {
         $uri->setPath($uri->getPath() . $path);
     }
     $response = $this->browser->request($uri, $method, $arguments, array(), array(), is_array($content) ? json_encode($content) : $content);
     return new Response($response, $this->browser->getLastRequest());
 }
 /**
  * @test
  */
 public function removingObjectTriggersIndexRemoval()
 {
     $testEntity = $this->createAndPersistTestEntity();
     $identifier = $this->persistenceManager->getIdentifierByObject($testEntity);
     $initialDocument = $this->testClient->findIndex('flow3_elasticsearch_functionaltests_twitter')->findType('tweet')->findDocumentById($identifier);
     $this->assertInstanceOf('Flowpack\\ElasticSearch\\Domain\\Model\\Document', $initialDocument);
     $persistedTestEntity = $this->testEntityRepository->findByIdentifier($identifier);
     $this->testEntityRepository->remove($persistedTestEntity);
     $this->persistenceManager->persistAll();
     $this->persistenceManager->clearState();
     $foundDocument = $this->testClient->findIndex('flow3_elasticsearch_functionaltests_twitter')->findType('tweet')->findDocumentById($identifier);
     $this->assertNull($foundDocument);
 }
Пример #4
0
 /**
  * @return array|null
  */
 protected function getSettings()
 {
     if ($this->client instanceof Client) {
         $settings = Arrays::getValueByPath($this->settings, 'indexes.' . $this->client->getBundle() . '.' . $this->settingsKey) ?: Arrays::getValueByPath($this->settings, 'indexes.default' . '.' . $this->settingsKey);
     } else {
         $settings = Arrays::getValueByPath($this->settings, 'indexes.default' . '.' . $this->settingsKey);
     }
     return $settings;
 }