# .NET Client max\_children in nested sorting

**URL:** <https://discuss.elastic.co/t/net-client-max-children-in-nested-sorting/228126>\
**Category:** Elasticsearch\
**Created:** [April 15, 2020, 12:48pm UTC](https://discuss.elastic.co/t/net-client-max-children-in-nested-sorting/228126 "2020-04-15T12:48:24Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Kurmann](https://avatars.discourse-cdn.com/v4/letter/k/8baadc/32.png) [@Kurmann](https://discuss.elastic.co/u/Kurmann)\
**Post date:** [April 15, 2020, 12:48pm UTC](https://discuss.elastic.co/t/net-client-max-children-in-nested-sorting/228126/1 "2020-04-15T12:48:25Z")

</div>

Hi.  
I need to set the property max\_children in a nested sort im .NET client.

This question was already answered for version 6.x here: [Closed Discussion](https://discuss.elastic.co/t/net-client-include-max-children-property-in-nested-sorting/161472) and here: [Stack Overflow](https://stackoverflow.com/questions/53847367/net-client-include-max-children-property-in-nested-sorting/53952473#53952473), but I didn't found it for Version 7.x

The solution there doesn't work. Explained [Here](https://www.elastic.co/guide/en/elasticsearch/client/net-api/7.x/custom-serialization.html#_jsonnetserializer)

---

<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:** [April 16, 2020, 12:50am UTC](https://discuss.elastic.co/t/net-client-max-children-in-nested-sorting/228126/2 "2020-04-16T00:50:06Z")

</div>

I've opened [https://github.com/elastic/elasticsearch-net/pull/4596](https://github.com/elastic/elasticsearch-net/pull/4596) to add in the next release.

For now, you'd be able to submit an API call to the low level client with `max_children`, and return a high level response. For example,

```auto
var client = new ElasticClient();

var searchResponse = client.LowLevel.Search<SearchResponse<MyDocument>>(
    "my_index", 
    PostData.Serializable(
	new 
	{
		query = new
		{
			match_all = new {}
		},
		sort = new object[]
		{
			new Dictionary<string, object>
			{
				{
					"tags.added", new
					{
						nested = new
						{
							path = "tags",
							filter = new
							{
								match_all = new { }
							},
							max_children = 50
						}
					}
				}
			}
		}
	}));

```

---

<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:** [May 14, 2020, 12:50am UTC](https://discuss.elastic.co/t/net-client-max-children-in-nested-sorting/228126/3 "2020-05-14T00:50:10Z")

</div>

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