/** * @param bool|null $recreate */ protected function _createIndex($recreate = null) { $this->getIndex()->create($this->_indexParams, $recreate); $mapping = new Elastica\Type\Mapping($this->getType(), $this->_mapping); $mapping->setSource(array('enabled' => $this->_source)); $mapping->send(); }
protected function mapping() { // Set mapping only if mapping is set and if type does not exist if ($this->mapping && !$this->typeExist($this->current_type)) { $ESmapping = new \Elastica\Type\Mapping(); $ESmapping->setType($this->elasticaType); //If Language supported by ES if (array_key_exists($this->lang, $this->langAnalyzer)) { $ESmapping->setParam("index_analyzer", $this->lang . "_Analyzer"); $ESmapping->setParam("search_analyzer", $this->lang . "_Analyzer"); } else { $ESmapping->setParam("index_analyzer", "default"); $ESmapping->setParam("search_analyzer", "default"); } if ($this->boost == "") { $this->boost = 1.0; } $ESmapping->setParam('_boost', array('name' => 'boost', 'null_value' => $this->boost)); if ($this->sourceExcludes) { $ESmapping->setSource(array('excludes' => $this->sourceExcludes)); } // Set mapping $ESmapping->setProperties($this->mapping); // Send mapping to type $ESmapping->send(); } }