Creating new indices with mapping and analyzers via config file

Hi there, I am trying to make all new indexes created use a default mapping for string types that includes both an analyzer and search_analyzer via the .yml configuration file. In my example, I have the following section under the index: section.

index:
    analysis:
        analyzer:
            default:
                tokenizer: keyword
                filter: lowercase
            autocomplete:
                type: custom
                tokenizer: standard
                filter: [lowercase, autocomplete_filter]
        filter:
            autocomplete_filter:
                type: edge_ngram
                min_gram: 1
                max_gram: 20
    mappings:
        _default_:
            dynamic_templates:
                strings:
                    match_mapping_type: string
                    mapping:
                        type: string
                        analyzer: autocomplete
                        search_analyzer: standard
                        index: analyzed
                        fields:
                            raw:
                                type: string
                                index: not_analyzed

However when I create my indices and all types are mapped, none of the above settings in being honored. I can however use the 'autocomplete' analyzer to tokenize an incoming term, but it is not applied to any of the fields in a way that I would have expected from following Index-Time Search-as-You-Type.

In my scenario, dynamic mapping is the only method we use and inserting this mapping via configuration is my only option to get it in there. Any guidance to resolve this issue is greatly appreciated.

Thanks

dynamic_templates should be an array and your golden

dynamic_templates:
    - strings:
        match_mapping_type: string

json is easier if u start using a lot of templates IMO :slight_smile:

Thanks eriktrom, unfortunately that did not seem to get the mappings applied to the index either. I guess I'll have to keep investigating ways to get it to work.