# Create a mapping from the JSON File to the index

**URL:** <https://discuss.elastic.co/t/create-a-mapping-from-the-json-file-to-the-index/117679>\
**Category:** Elasticsearch\
**Created:** [January 30, 2018, 6:03pm UTC](https://discuss.elastic.co/t/create-a-mapping-from-the-json-file-to-the-index/117679 "2018-01-30T18:03:10Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![tejaswicwd](https://avatars.discourse-cdn.com/v4/letter/t/cab0a1/32.png) [@tejaswicwd](https://discuss.elastic.co/u/tejaswicwd)\
**Post date:** [January 30, 2018, 6:03pm UTC](https://discuss.elastic.co/t/create-a-mapping-from-the-json-file-to-the-index/117679/1 "2018-01-30T18:03:10Z")

</div>

I want to define the mapping of the index in the JSON file. I am searching for using the proper NEST command to create an index by reading that file.  
I came across using the PostData and PUT commands, but quite not sure on how to develop on it.  
I am using [Elasticsearch.Net](http://Elasticsearch.Net) and NEST: the .NET clients [5.5] documentation to follow up on these.

I was using the below code to create index and do mapping. But now it doesn't work for the search bar properly.

public static void InitCredential()  
{

```
        if ( !EC.IndexExists( CredentialIndex ).Exists )
        {
            // .String(s => s.Index(FieldIndexOption.NotAnalyzed).Name(n => n.Name))
            EC.CreateIndex( CredentialIndex, c => new CreateIndexDescriptor( CredentialIndex )
                .Mappings( ms => ms
                    .Map<CredentialIndex>( m => m
                        .AutoMap()
                        .Properties( p => p
                          .Text( s => s.Index( true ).Name( n => n.Name ).Fielddata( true ) )
                            .Nested<IndexSubject>( n => n
                                .Name( nn => nn.Subjects )
                                .AutoMap()
                            )
                           .Nested<IndexReferenceFramework>( n => n
                                .Name( nn => nn.Frameworks )
                                .AutoMap()
                            )
                            .Nested<IndexCompetency>( n => n
                                .Name( nn => nn.Competencies )
                                .AutoMap()
                            )
                             //.GeoPoint( g => g.Name( n => n.AddressLocations ) )
                             .Nested<Models.Elastic.Address>( n => n
                                .Name( nn => nn.Addresses )
                                .AutoMap()
                            )
                        )
                    )
                )
            );
        }
    }
```

---

<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:** [February 27, 2018, 6:03pm UTC](https://discuss.elastic.co/t/create-a-mapping-from-the-json-file-to-the-index/117679/2 "2018-02-27T18:03:13Z")

</div>

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