# NEST (C#) How to disable any automatic mapping and ensure only manually coded fields added to index

**URL:** <https://discuss.elastic.co/t/nest-c-how-to-disable-any-automatic-mapping-and-ensure-only-manually-coded-fields-added-to-index/145078>\
**Category:** Elasticsearch\
**Created:** [August 20, 2018, 2:27am UTC](https://discuss.elastic.co/t/nest-c-how-to-disable-any-automatic-mapping-and-ensure-only-manually-coded-fields-added-to-index/145078 "2018-08-20T02:27:05Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![ivankarpey](https://avatars.discourse-cdn.com/v4/letter/i/a5b964/32.png) [@ivankarpey](https://discuss.elastic.co/u/ivankarpey)\
**Post date:** [August 20, 2018, 2:27am UTC](https://discuss.elastic.co/t/nest-c-how-to-disable-any-automatic-mapping-and-ensure-only-manually-coded-fields-added-to-index/145078/1 "2018-08-20T02:27:05Z")

</div>

I have a mapping with fluent syntaxis where I carefully set only those fields I need. However when I add document to those index, i still see all fields from the object except thouse, who I manually add to ingore.

I don't really call something similar to`.Automap()` anywhere but it looks like it's a defult behaviour. How could I disable it and let only selected fields come to index, instead of all of them?

---

<div class="post-metadata">

**Author:** ![Bernt\_Rostad](https://avatars.discourse-cdn.com/v4/letter/b/3ab097/32.png) [@Bernt\_Rostad](https://discuss.elastic.co/u/Bernt_Rostad)\
**Post date:** [August 20, 2018, 4:17am UTC](https://discuss.elastic.co/t/nest-c-how-to-disable-any-automatic-mapping-and-ensure-only-manually-coded-fields-added-to-index/145078/2 "2018-08-20T04:17:22Z")

</div>

> [@ivankarpey](#):
>
> How could I disable it and let only selected fields come to index,

You need to specify the **dynamic** setting in your Index mapping. If you set it to **false** all fields not defined in the mapping will be silently ignored while if you set it to **strict** an exception is raised and the document fail to be indexed. See [dynamic Mapping parameter](https://www.elastic.co/guide/en/elasticsearch/reference/current/dynamic.html).

---

<div class="post-metadata">

**Author:** ![forloop](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/forloop/32/9021_2.png) [@forloop](https://discuss.elastic.co/u/forloop)\
**Post date:** [August 20, 2018, 8:23am UTC](https://discuss.elastic.co/t/nest-c-how-to-disable-any-automatic-mapping-and-ensure-only-manually-coded-fields-added-to-index/145078/3 "2018-08-20T08:23:54Z")

</div>

@Bernt_Rostad is correct. You can set this behaviour in NEST when creating the index

```auto
var createIndexResponse = client.CreateIndex("my_index", c => c
    .Mappings(m => m
        .Map<MyDocument>(mm => mm
            .Dynamic(false)
        )
    )
);

```

or if the index already exists

```auto
var putMappingResponse = client.Map<MyDocument>(m => m
    .Index("my_index")
    .Dynamic(false)
)

```

---

<div class="post-metadata">

**Author:** ![ivankarpey](https://avatars.discourse-cdn.com/v4/letter/i/a5b964/32.png) [@ivankarpey](https://discuss.elastic.co/u/ivankarpey)\
**Post date:** [August 27, 2018, 11:44am UTC](https://discuss.elastic.co/t/nest-c-how-to-disable-any-automatic-mapping-and-ensure-only-manually-coded-fields-added-to-index/145078/4 "2018-08-27T11:44:45Z")

</div>

@forloop @Bernt_Rostad Thanks a lot

---

<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:** [September 24, 2018, 11:44am UTC](https://discuss.elastic.co/t/nest-c-how-to-disable-any-automatic-mapping-and-ensure-only-manually-coded-fields-added-to-index/145078/5 "2018-09-24T11:44:52Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
