Classes/Driver/Version5/Mapping/NodeTypeMappingBuilder.php
protected function adjustStringTypeMapping(array &$mapping): void
    {
        $adjustStringTypeMapping = function (&$item) {
            if (isset($item['type']) && $item['type'] === 'string') {
                if (isset($item['index'])) {
                    if ($item['index'] === 'not_analyzed') {
                        $item['type'] = 'keyword';
                        $item['index'] = true;
                        unset($item['analyzer']);
                    } elseif ($item['index'] === 'no') {
                        $item['type'] = 'text';
                        $item['index'] = false;
                    } elseif ($item['index'] === 'analyzed') {
                        $item['type'] = 'text';
                        $item['index'] = true;
                    }
                } else {
                    $item['type'] = 'keyword';
                    $item['index'] = true;
                }
            }
        };

        $adjustStringTypeMapping($mapping);

        foreach ($mapping as &$item) {
            if (is_array($item)) {
                $adjustStringTypeMapping($mapping);
                $this->adjustStringTypeMapping($item);
            }
        }
    }
protected function adjustStringTypeMapping(array &$mapping): void
    {
        $adjustStringTypeMapping = function (&$item) {
            if (isset($item['type']) && $item['type'] === 'string') {
                if (isset($item['index'])) {
                    if ($item['index'] === 'not_analyzed') {
                        $item['type'] = 'keyword';
                        $item['index'] = true;
                        unset($item['analyzer']);
                    } elseif ($item['index'] === 'no') {
                        $item['type'] = 'text';
                        $item['index'] = false;
                    } elseif ($item['index'] === 'analyzed') {
                        $item['type'] = 'text';
                        $item['index'] = true;
                    }
                } else {
                    $item['type'] = 'keyword';
                    $item['index'] = true;
                }
            }
        };

        $adjustStringTypeMapping($mapping);

        foreach ($mapping as &$item) {
            if (is_array($item)) {
                $adjustStringTypeMapping($mapping);
                $this->adjustStringTypeMapping($item);
            }
        }
    }
protected function adjustStringTypeMapping ( array & $ mapping ) : void { $ adjustStringTypeMapping = function ( & $ item ) { if ( isset ( $ item [ 'type' ] ) && $ item [ 'type' ] === 'string' ) { if ( isset ( $ item [ 'index' ] ) ) { if ( $ item [ 'index' ] === 'not_analyzed' ) { $ item [ 'type' ] = 'keyword' ; $ item [ 'index' ] = true ; unset ( $ item [ 'analyzer' ] ) ; } elseif ( $ item [ 'index' ] === 'no' ) { $ item [ 'type' ] = 'text' ; $ item [ 'index' ] = false ; } elseif ( $ item [ 'index' ] === 'analyzed' ) { $ item [ 'type' ] = 'text' ; $ item [ 'index' ] = true ; } } else { $ item [ 'type' ] = 'keyword' ; $ item [ 'index' ] = true ; } } } ; $ adjustStringTypeMapping ( $ mapping ) ; foreach ( $ mapping as & $ item ) { if ( is_array ( $ item ) ) { $ adjustStringTypeMapping ( $ mapping ) ; $ this -> adjustStringTypeMapping ( $ item ) ; } } }
Adjust the mapping for string to text or keyword as needed.

This is used to ease moving from ES 1.x and 2.x to 5.x by migrating the
mapping like this:

| 2.x                                       | 5.x                              |
|-------------------------------------------|----------------------------------|
| "type": "string", "index": "no"           | "type": "text", "index": false   |
| "type": "string", "index": "analyzed"     | "type": "text", "index": true    |
| "type": "string", "index": "not_analyzed" | "type": "keyword", "index": true |

@param array &$mapping
@return void
Adjust the mapping for string to text or keyword as needed .