# Creating new indices with mapping and analyzers via config file

**URL:** <https://discuss.elastic.co/t/creating-new-indices-with-mapping-and-analyzers-via-config-file/59444>\
**Category:** Elasticsearch\
**Created:** [August 31, 2016, 4:05pm UTC](https://discuss.elastic.co/t/creating-new-indices-with-mapping-and-analyzers-via-config-file/59444 "2016-08-31T16:05:25Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Spentland](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/spentland/32/11707_2.png) [@Spentland](https://discuss.elastic.co/u/Spentland)\
**Post date:** [August 31, 2016, 4:05pm UTC](https://discuss.elastic.co/t/creating-new-indices-with-mapping-and-analyzers-via-config-file/59444/1 "2016-08-31T16:05:25Z")

</div>

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](https://www.elastic.co/guide/en/elasticsearch/guide/current/_index_time_search_as_you_type.html).

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

---

<div class="post-metadata">

**Author:** ![eriktrom](https://avatars.discourse-cdn.com/v4/letter/e/e495f1/32.png) [@eriktrom](https://discuss.elastic.co/u/eriktrom)\
**Post date:** [September 1, 2016, 10:27am UTC](https://discuss.elastic.co/t/creating-new-indices-with-mapping-and-analyzers-via-config-file/59444/2 "2016-09-01T10:27:11Z")

</div>

dynamic\_templates should be an array and your golden

```auto
dynamic_templates:
    - strings:
        match_mapping_type: string

```

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

---

<div class="post-metadata">

**Author:** ![Spentland](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/spentland/32/11707_2.png) [@Spentland](https://discuss.elastic.co/u/Spentland)\
**Post date:** [September 1, 2016, 1:29pm UTC](https://discuss.elastic.co/t/creating-new-indices-with-mapping-and-analyzers-via-config-file/59444/3 "2016-09-01T13:29:53Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [July 5, 2017, 10:23pm UTC](https://discuss.elastic.co/t/creating-new-indices-with-mapping-and-analyzers-via-config-file/59444/4 "2017-07-05T22:23:15Z")

</div>

Closed on July 5, 2017, 10:23pm UTC


