public function createMap() {
        if(is_null($this->schema)) {
            throw SystemException::forNoSchema();
        }

        // translate data first to sql
        $data = $this->schema->toSql();

        // then translate it to elastic mapping
        $mapping = $this->schema->toElastic($data);
        // get schema path
        $path = cradle()->package('global')->path('schema') . '/elastic';
        // if elastic dir doesn't exists
        // create elastic folder
        if(!is_dir($path)) {
            mkdir($path, 0777);
        }

        // if elastic schema dir doesn't exist
        // create elastic schema dir
        mkdir ($path . '/' . ucwords($data['name']));

        // save mapping
        file_put_contents(
            $path . '/' . ucwords($data['name']) . '/elastic.php',
            '<?php //-->' . "\n return " .
            var_export($mapping, true) . ';'
        );
    }