# How to add custom index descriptor mapping to added fields (Nest .net)

**URL:** <https://discuss.elastic.co/t/how-to-add-custom-index-descriptor-mapping-to-added-fields-nest-net/267958>\
**Category:** Elasticsearch\
**Created:** [March 22, 2021, 8:24am UTC](https://discuss.elastic.co/t/how-to-add-custom-index-descriptor-mapping-to-added-fields-nest-net/267958 "2021-03-22T08:24:20Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Nicolas\_Rey](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/nicolas_rey/32/47284_2.png) [@Nicolas\_Rey](https://discuss.elastic.co/u/Nicolas_Rey)\
**Post date:** [March 22, 2021, 8:24am UTC](https://discuss.elastic.co/t/how-to-add-custom-index-descriptor-mapping-to-added-fields-nest-net/267958/1 "2021-03-22T08:24:20Z")

</div>

Hi,

I use a repository to deal with Elasticsearch CRUD operations. It works but I face a problem :  
when I add fields to an existing index I don't know how to apply custom Index Descriptor. It works with an AutoMap but if I need any kind of custom how should I do ?

```auto
        public ElasticSearchRepository(IElasticClient elasticClient, string index, Func<CreateIndexDescriptor, ICreateIndexRequest> indexDescriptor)
        {
            _elasticClient = elasticClient;
            _index = index.ToLower();

            var exist = _elasticClient.Indices.Exists(_index);
            if (!exist.Exists)
            {
                var res = _elasticClient.Indices.Create(_index, indexDescriptor);

                if (!res.IsValid)
                    throw res.OriginalException;
            }
            else
            {
                // Try to apply potential added mappings
                var mapResponse = _elasticClient.Map<T>(x => x.Index(_index).AutoMap()); // <==== here I can apply AutoMap, but how to use my custom indexDescriptor ???
                if (!mapResponse.IsValid)
                    throw mapResponse.OriginalException;
            }

```

Thank you!

---

<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:** [April 19, 2021, 8:24am UTC](https://discuss.elastic.co/t/how-to-add-custom-index-descriptor-mapping-to-added-fields-nest-net/267958/2 "2021-04-19T08:24:41Z")

</div>

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