src/Schema/Service/ElasticService.php
public function map() {
        // no schema validation
        if(is_null($this->schema)) {
            throw SystemException::forNoSchema();
        }

        $table = $this->schema->getName();
        $path = cradle()->package('global')->path('schema')
              . sprintf('/elastic/%s/elastic.php', ucwords($table));

        // if mapped file doesn't exist,
        // do nothing
        if (!file_exists($path)) {
            return false;
        }

        $data = include_once($path);

        // try mapping
        try {
            $this->resource->indices()->create(['index' => $table]);
            $this->resource->indices()->putMapping([
                'index' => $table,
                'type' => 'main',
                'body' => [
                    '_source' => [
                        'enabled' => true
                    ],
                    'properties' => $data[$table]
                ]
            ]);
        } catch (NoNodesAvailableException $e) {
            //because there is no reason to continue;
            return false;
        } catch (BadRequest400Exception $e) {
            //already mapped
            return false;
        } catch (\Throwable $e) {
            // something is not right
            return false;
        }

        return true;
    }
public function map() {
        // no schema validation
        if(is_null($this->schema)) {
            throw SystemException::forNoSchema();
        }

        $table = $this->schema->getName();
        $path = cradle()->package('global')->path('schema')
              . sprintf('/elastic/%s/elastic.php', ucwords($table));

        // if mapped file doesn't exist,
        // do nothing
        if (!file_exists($path)) {
            return false;
        }

        $data = include_once($path);

        // try mapping
        try {
            $this->resource->indices()->create(['index' => $table]);
            $this->resource->indices()->putMapping([
                'index' => $table,
                'type' => 'main',
                'body' => [
                    '_source' => [
                        'enabled' => true
                    ],
                    'properties' => $data[$table]
                ]
            ]);
        } catch (NoNodesAvailableException $e) {
            //because there is no reason to continue;
            return false;
        } catch (BadRequest400Exception $e) {
            //already mapped
            return false;
        } catch (\Throwable $e) {
            // something is not right
            return false;
        }

        return true;
    }
public function map ( ) { // no schema validation if ( is_null ( $ this -> schema ) ) { throw SystemException :: forNoSchema ( ) ; } $ table = $ this -> schema -> getName ( ) ; $ path = cradle ( ) -> package ( 'global' ) -> path ( 'schema' ) . sprintf ( '/elastic/%s/elastic.php' , ucwords ( $ table ) ) ; // if mapped file doesn't exist, // do nothing if ( ! file_exists ( $ path ) ) { return false ; } $ data = include_once ( $ path ) ; // try mapping try { $ this -> resource -> indices ( ) -> create ( [ 'index' => $ table ] ) ; $ this -> resource -> indices ( ) -> putMapping ( [ 'index' => $ table , 'type' => 'main' , 'body' => [ '_source' => [ 'enabled' => true ] , 'properties' => $ data [ $ table ] ] ] ) ; } catch ( NoNodesAvailableException $ e ) { //because there is no reason to continue; return false ; } catch ( BadRequest400Exception $ e ) { //already mapped return false ; } catch ( \ Throwable $ e ) { // something is not right return false ; } return true ; }
Map Elastic Schema

@return bool
Map Elastic Schema