public function testAddTypeConstrainedMapping() { $mapping = new \ElasticSearchMapping(array('tweet' => array('type' => 'string')), array('type' => 'tweet')); $exported = $mapping->export(); $this->assert->array($exported)->isNotEmpty()->hasKey('properties')->notHasKey('type'); }
/** * Puts a mapping on index * * @param array|object $mapping * @param array $config * @throws Exception * @return array */ public function map($mapping, $config = array()) { if (is_array($mapping)) { $mapping = new ElasticSearchMapping($mapping); } $mapping->config($config); try { $type = $mapping->config('type'); } catch (Exception $e) { } // No type is cool if (isset($type) && !$this->passesTypeConstraint($type)) { throw new ElasticSearchException("Cant create mapping due to type constraint mismatch"); } return $this->request('_mapping', 'PUT', $mapping->export(), true); }