private function getDefaultIndexParams()
    {
        $analyzers = Config::get('larasearch.elasticsearch.analyzers');
        $params = Config::get('larasearch.elasticsearch.defaults.index');
        $mapping = [];

        $mapping_options = array_combine(
            $analyzers,
            array_map(function ($type)
                {
                    $config = $this->getProxy()->getConfig();

                    // Maintain backwards compatibility by allowing a plain array of analyzer => fields
                    $field_mappings = Utils::findKey($config, $type, false) ?: [];

                    // Also read from a dedicated array key called 'analyzers'
                    if (isset($config['analyzers']))
                    {
                        $field_mappings = array_merge($field_mappings, Utils::findKey($config['analyzers'], $type, false) ?: []);
                    }

                    return $field_mappings;
                },
                $analyzers
            )
        );

        foreach (array_unique(array_flatten(array_values($mapping_options))) as $field)
        {
            // Extract path segments from dot separated field
            $pathSegments = explode('.', $field);

            // Last element is the field name
            $fieldName = array_pop($pathSegments);

            // Apply default field mapping
            $fieldMapping = [
                'type' => "multi_field",
                'fields' => [
                    $fieldName => [
                        'type' => 'string',
                        'index' => 'not_analyzed'
                    ],
                    'analyzed' => [
                        'type' => 'string',
                        'index' => 'analyzed'
                    ]
                ]
            ];

            // Check if we need to add additional mappings
            foreach ($mapping_options as $type => $fields)
            {
                if (in_array($field, $fields))
                {
                    $fieldMapping['fields'][$type] = [
                        'type' => 'string',
                        'index' => 'analyzed',
                        'analyzer' => "larasearch_${type}_index"
                    ];
                }
            }

            if (!empty($pathSegments))
            {
                $mapping = Utils::array_merge_recursive_distinct(
                    $mapping,
                    $this->getNestedFieldMapping($fieldName, $fieldMapping, $pathSegments)
                );
            } else
            {
                $mapping[$fieldName] = $fieldMapping;
            }
        }

        if (!empty($mapping)) $params['mappings']['_default_']['properties'] = $mapping;

        $params['index'] = $this->getName();
        $params['type'] = $this->getProxy()->getType();

        return $params;
    }
private function getDefaultIndexParams()
    {
        $analyzers = Config::get('larasearch.elasticsearch.analyzers');
        $params = Config::get('larasearch.elasticsearch.defaults.index');
        $mapping = [];

        $mapping_options = array_combine(
            $analyzers,
            array_map(function ($type)
                {
                    $config = $this->getProxy()->getConfig();

                    // Maintain backwards compatibility by allowing a plain array of analyzer => fields
                    $field_mappings = Utils::findKey($config, $type, false) ?: [];

                    // Also read from a dedicated array key called 'analyzers'
                    if (isset($config['analyzers']))
                    {
                        $field_mappings = array_merge($field_mappings, Utils::findKey($config['analyzers'], $type, false) ?: []);
                    }

                    return $field_mappings;
                },
                $analyzers
            )
        );

        foreach (array_unique(array_flatten(array_values($mapping_options))) as $field)
        {
            // Extract path segments from dot separated field
            $pathSegments = explode('.', $field);

            // Last element is the field name
            $fieldName = array_pop($pathSegments);

            // Apply default field mapping
            $fieldMapping = [
                'type' => "multi_field",
                'fields' => [
                    $fieldName => [
                        'type' => 'string',
                        'index' => 'not_analyzed'
                    ],
                    'analyzed' => [
                        'type' => 'string',
                        'index' => 'analyzed'
                    ]
                ]
            ];

            // Check if we need to add additional mappings
            foreach ($mapping_options as $type => $fields)
            {
                if (in_array($field, $fields))
                {
                    $fieldMapping['fields'][$type] = [
                        'type' => 'string',
                        'index' => 'analyzed',
                        'analyzer' => "larasearch_${type}_index"
                    ];
                }
            }

            if (!empty($pathSegments))
            {
                $mapping = Utils::array_merge_recursive_distinct(
                    $mapping,
                    $this->getNestedFieldMapping($fieldName, $fieldMapping, $pathSegments)
                );
            } else
            {
                $mapping[$fieldName] = $fieldMapping;
            }
        }

        if (!empty($mapping)) $params['mappings']['_default_']['properties'] = $mapping;

        $params['index'] = $this->getName();
        $params['type'] = $this->getProxy()->getType();

        return $params;
    }
private function getDefaultIndexParams ( ) { $ analyzers = Config :: get ( 'larasearch.elasticsearch.analyzers' ) ; $ params = Config :: get ( 'larasearch.elasticsearch.defaults.index' ) ; $ mapping = [ ] ; $ mapping_options = array_combine ( $ analyzers , array_map ( function ( $ type ) { $ config = $ this -> getProxy ( ) -> getConfig ( ) ; // Maintain backwards compatibility by allowing a plain array of analyzer => fields $ field_mappings = Utils :: findKey ( $ config , $ type , false ) ? : [ ] ; // Also read from a dedicated array key called 'analyzers' if ( isset ( $ config [ 'analyzers' ] ) ) { $ field_mappings = array_merge ( $ field_mappings , Utils :: findKey ( $ config [ 'analyzers' ] , $ type , false ) ? : [ ] ) ; } return $ field_mappings ; } , $ analyzers ) ) ; foreach ( array_unique ( array_flatten ( array_values ( $ mapping_options ) ) ) as $ field ) { // Extract path segments from dot separated field $ pathSegments = explode ( '.' , $ field ) ; // Last element is the field name $ fieldName = array_pop ( $ pathSegments ) ; // Apply default field mapping $ fieldMapping = [ 'type' => "multi_field" , 'fields' => [ $ fieldName => [ 'type' => 'string' , 'index' => 'not_analyzed' ] , 'analyzed' => [ 'type' => 'string' , 'index' => 'analyzed' ] ] ] ; // Check if we need to add additional mappings foreach ( $ mapping_options as $ type => $ fields ) { if ( in_array ( $ field , $ fields ) ) { $ fieldMapping [ 'fields' ] [ $ type ] = [ 'type' => 'string' , 'index' => 'analyzed' , 'analyzer' => "larasearch_${type}_index" ] ; } } if ( ! empty ( $ pathSegments ) ) { $ mapping = Utils :: array_merge_recursive_distinct ( $ mapping , $ this -> getNestedFieldMapping ( $ fieldName , $ fieldMapping , $ pathSegments ) ) ; } else { $ mapping [ $ fieldName ] = $ fieldMapping ; } } if ( ! empty ( $ mapping ) ) $ params [ 'mappings' ] [ '_default_' ] [ 'properties' ] = $ mapping ; $ params [ 'index' ] = $ this -> getName ( ) ; $ params [ 'type' ] = $ this -> getProxy ( ) -> getType ( ) ; return $ params ; }
Initialize the default index settings and mappings

@return array
Initialize the default index settings and mappings