yii\elasticsearch\Command::setMapping PHP Method

setMapping() public method

See also: http://www.elastic.co/guide/en/elasticsearch/reference/current/indices-put-mapping.html
public setMapping ( string $index, string $type, string | array $mapping, array $options = [] ) : mixed
$index string
$type string
$mapping string | array
$options array
return mixed
    public function setMapping($index, $type, $mapping, $options = [])
    {
        $body = $mapping !== null ? is_string($mapping) ? $mapping : Json::encode($mapping) : null;
        return $this->db->put([$index, '_mapping', $type], $options, $body);
    }

Usage Example

コード例 #1
0
 /**
  * sets up the index for this record
  * @param Command $command
  * @param boolean $statusIsBoolean
  */
 public static function setUpMapping($command, $statusIsBoolean = false)
 {
     $command->deleteMapping(static::index(), static::type());
     $command->setMapping(static::index(), static::type(), [static::type() => ["_id" => ["path" => "id", "index" => "not_analyzed", "store" => "yes"], "properties" => ["name" => ["type" => "string", "index" => "not_analyzed"], "email" => ["type" => "string", "index" => "not_analyzed"], "address" => ["type" => "string", "index" => "analyzed"], "status" => $statusIsBoolean ? ["type" => "boolean"] : ["type" => "integer"]]]]);
 }
All Usage Examples Of yii\elasticsearch\Command::setMapping