# Nest Inferred mappings output

**URL:** https://discuss.elastic.co/t/nest-inferred-mappings-output/73783
**Category:** Elasticsearch
**Created:** [February 3, 2017, 3:36am UTC](https://discuss.elastic.co/t/nest-inferred-mappings-output/73783 "2017-02-03T03:36:16Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![shakdoesspark](https://avatars.discourse-cdn.com/v4/letter/s/dec6dc/32.png) [@shakdoesspark](https://discuss.elastic.co/u/shakdoesspark)
#### Post date: [February 3, 2017, 3:36am UTC](https://discuss.elastic.co/t/nest-inferred-mappings-output/73783/1 "2017-02-03T03:36:16Z")

</div>

Hi,

I'm using the Nest library and trying to get what the inferred mapping is in JSON.

---

<div class="post-metadata">

### Author: ![warkolm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warkolm/32/39224_2.png) [@warkolm](https://discuss.elastic.co/u/warkolm)
#### Post date: [February 3, 2017, 4:19am UTC](https://discuss.elastic.co/t/nest-inferred-mappings-output/73783/2 "2017-02-03T04:19:24Z")

</div>

And are you looking for assistance with this?

---

<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: [February 3, 2017, 4:27am UTC](https://discuss.elastic.co/t/nest-inferred-mappings-output/73783/3 "2017-02-03T04:27:03Z")

</div>

You can capture the request and response using `OnRequestCompleted()` in conjunction with `.DisableDirectStreaming()`

```auto
void Main()
{
	var pool = new SingleNodeConnectionPool(new Uri("http://localhost:9200"));
	var defaultIndex = "default-index";
	var connectionSettings = new ConnectionSettings(pool)
			.DefaultIndex(defaultIndex)
			.PrettyJson()
			.DisableDirectStreaming()
			.OnRequestCompleted(response =>
				{
					// log out the request
					if (response.RequestBodyInBytes != null)
					{
						Console.WriteLine(
							$"{response.HttpMethod} {response.Uri} \n" +
							$"{Encoding.UTF8.GetString(response.RequestBodyInBytes)}");
					}
					else
					{
						Console.WriteLine($"{response.HttpMethod} {response.Uri}");
					}
                    
                    Console.WriteLine();

					// log out the response
					if (response.ResponseBodyInBytes != null)
					{
						Console.WriteLine($"Status: {response.HttpStatusCode}\n" +
								 $"{Encoding.UTF8.GetString(response.ResponseBodyInBytes)}\n" +
								 $"{new string('-', 30)}\n");
					}
					else
					{
						Console.WriteLine($"Status: {response.HttpStatusCode}\n" +
								 $"{new string('-', 30)}\n");
					}
				});
				
	var client = new ElasticClient(connectionSettings);
	
	if (client.IndexExists(defaultIndex).Exists)
		client.DeleteIndex(defaultIndex);

    client.CreateIndex(defaultIndex, c => c
        .Mappings(m => m
            .Map<Document>(mm => mm
                .AutoMap()
            )
        )
    );

}

public class Document
{
    public string Field1 { get; set;} 
}

```

this yields

```json
PUT http://localhost:9200/default-index?pretty=true 
{
  "mappings": {
    "document": {
      "properties": {
        "field1": {
          "type": "string"
        }
      }
    }
  }
}

```

You can also use a web debugging proxy such as [Fiddler](http://www.telerik.com/fiddler) to capture traffic.

---

<div class="post-metadata">

### Author: ![shakdoesspark](https://avatars.discourse-cdn.com/v4/letter/s/dec6dc/32.png) [@shakdoesspark](https://discuss.elastic.co/u/shakdoesspark)
#### Post date: [February 3, 2017, 4:52pm UTC](https://discuss.elastic.co/t/nest-inferred-mappings-output/73783/4 "2017-02-03T16:52:14Z")

</div>

Hi Russ,

Thanks for the help on that!  
Is there any way else besides making a request out to the cluster to get that json mapping?

---

<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: [February 6, 2017, 1:48am UTC](https://discuss.elastic.co/t/nest-inferred-mappings-output/73783/5 "2017-02-06T01:48:29Z")

</div>

> [@shakdoesspark](#):
>
> Is there any way else besides making a request out to the cluster to get that json mapping?

1. Use an `InMemoryConnection` on `ConnectionSettings`

2. pass the `CreateIndexDescriptor` or `CreateIndexRequest` to `client.Serializer`

---

<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: [March 6, 2017, 1:48am UTC](https://discuss.elastic.co/t/nest-inferred-mappings-output/73783/6 "2017-03-06T01:48:49Z")

</div>

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