public function testMappingBuilderStoreProperty() { $typeConfig = new TypeConfig('typename', ['properties' => ['storeless' => ['type' => 'string'], 'stored' => ['type' => 'string', 'store' => true], 'unstored' => ['type' => 'string', 'store' => false]]]); $mapping = $this->builder->buildTypeMapping($typeConfig); $this->assertArrayNotHasKey('store', $mapping['properties']['storeless']); $this->assertArrayHasKey('store', $mapping['properties']['stored']); $this->assertTrue($mapping['properties']['stored']['store']); $this->assertArrayHasKey('store', $mapping['properties']['unstored']); $this->assertFalse($mapping['properties']['unstored']['store']); }
public function testMappingBuilderStoreProperty() { $typeConfig = new TypeConfig('typename', array('properties' => array('storeless' => array('type' => 'string'), 'stored' => array('type' => 'string', 'store' => true), 'unstored' => array('type' => 'string', 'store' => false)), '_parent' => array('type' => 'parent_type', 'identifier' => 'name', 'property' => 'parent_property'))); $mapping = $this->builder->buildTypeMapping($typeConfig); $this->assertArrayNotHasKey('store', $mapping['properties']['storeless']); $this->assertArrayHasKey('store', $mapping['properties']['stored']); $this->assertTrue($mapping['properties']['stored']['store']); $this->assertArrayHasKey('store', $mapping['properties']['unstored']); $this->assertFalse($mapping['properties']['unstored']['store']); $this->assertArrayHasKey('_parent', $mapping); $this->assertArrayNotHasKey('identifier', $mapping['_parent']); $this->assertArrayNotHasKey('property', $mapping['_parent']); }
/** * Deletes and recreates a mapping type for the named index. * * @param string $indexName * @param string $typeName * * @throws \InvalidArgumentException if no index or type mapping exists for the given names * @throws ResponseException */ public function resetIndexType($indexName, $typeName) { $typeConfig = $this->configManager->getTypeConfiguration($indexName, $typeName); $index = $this->indexManager->getIndex($indexName); $type = $index->getType($typeName); $indexConfig = $this->configManager->getIndexConfiguration($indexName); $settings = $indexConfig->getSettings(); $event = new TypeResetEvent($indexName, $typeName); $this->dispatcher->dispatch(TypeResetEvent::PRE_TYPE_RESET, $event); try { $type->delete(); } catch (ResponseException $e) { if (strpos($e->getMessage(), 'TypeMissingException') === false) { throw $e; } } if (!empty($settings)) { $index->close(); $index->setSettings($settings); $index->open(); } $mapping = new Mapping(); foreach ($this->mappingBuilder->buildTypeMapping($typeConfig) as $name => $field) { $mapping->setParam($name, $field); } $type->setMapping($mapping); $this->dispatcher->dispatch(TypeResetEvent::POST_TYPE_RESET, $event); }
/** * Deletes and recreates a mapping type for the named index * * @param string $indexName * @param string $typeName * @throws \InvalidArgumentException if no index or type mapping exists for the given names * @throws ResponseException */ public function resetIndexType($indexName, $typeName) { $typeConfig = $this->configManager->getTypeConfiguration($indexName, $typeName); $type = $this->indexManager->getIndex($indexName)->getType($typeName); try { $type->delete(); } catch (ResponseException $e) { if (strpos($e->getMessage(), 'TypeMissingException') === false) { throw $e; } } $mapping = new Mapping(); foreach ($this->mappingBuilder->buildTypeMapping($typeConfig) as $name => $field) { $mapping->setParam($name, $field); } $type->setMapping($mapping); }
/** * Deletes and recreates a mapping type for the named index. * * @param string $indexName * @param string $typeName * * @throws \InvalidArgumentException if no index or type mapping exists for the given names * @throws ResponseException */ public function resetIndexType($indexName, $typeName) { $typeConfig = $this->configManager->getTypeConfiguration($indexName, $typeName); $this->resetIndex($indexName, true); $index = $this->indexManager->getIndex($indexName); $type = $index->getType($typeName); $event = new TypeResetEvent($indexName, $typeName); $this->dispatcher->dispatch(TypeResetEvent::PRE_TYPE_RESET, $event); if (!empty($settings)) { unset($settings['number_of_shards']); $index->close(); $index->setSettings($settings); $index->open(); } $mapping = new Mapping(); foreach ($this->mappingBuilder->buildTypeMapping($typeConfig) as $name => $field) { $mapping->setParam($name, $field); } $type->setMapping($mapping); $this->dispatcher->dispatch(TypeResetEvent::POST_TYPE_RESET, $event); }