/** * 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 string $path * @param array $arguments * @param string $content * * @throws \Flowpack\ElasticSearch\Exception * @return \Flowpack\ElasticSearch\Transfer\Response */ public function request($method, $path = null, $arguments = array(), $content = null) { if ($this->client === null) { throw new Exception('The client of the index "' . $this->name . '" is not set, hence no requests can be done.'); } $path = '/' . $this->name . ($path ?: ''); return $this->client->request($method, $path, $arguments, $content); }