# NEST Driver is adding extra "pattern" element to "include"

**URL:** https://discuss.elastic.co/t/nest-driver-is-adding-extra-pattern-element-to-include/79658
**Category:** Elasticsearch
**Created:** [March 22, 2017, 11:09pm UTC](https://discuss.elastic.co/t/nest-driver-is-adding-extra-pattern-element-to-include/79658 "2017-03-22T23:09:41Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![wolczas](https://avatars.discourse-cdn.com/v4/letter/w/a88e4f/32.png) [@wolczas](https://discuss.elastic.co/u/wolczas)
#### Post date: [March 22, 2017, 11:09pm UTC](https://discuss.elastic.co/t/nest-driver-is-adding-extra-pattern-element-to-include/79658/1 "2017-03-22T23:09:41Z")

</div>

Howdy,

I'm having an issue with using Include element from DSL in Nest syntax.

When Nest request is serialized it adds extra "pattern" element in DSL which prevents aggs below from being evaluated:

Nest Syntax:

Func\<AggregationContainerDescriptor, IAggregationContainer\> catPathagg = oo =\> oo.Terms("catpaths", term =\> term  
&nbsp;&nbsp;&nbsp;.Field("categories.categoryPath")  
&nbsp;&nbsp;&nbsp;.Aggregations(depthAgg)  
&nbsp;&nbsp;&nbsp;._Include(@"(/[^/]+){2}","")_  
&nbsp;&nbsp;&nbsp;);

DSL generated:

"aggs": { "catpaths": {  
&nbsp;&nbsp;&nbsp;"terms": {  
&nbsp;&nbsp;&nbsp;"field": "categories.categoryPath",  
&nbsp;&nbsp;&nbsp;"_include": {_  
&nbsp;&nbsp;&nbsp; **"pattern"** : "(/[^/]+){2}"  
&nbsp;&nbsp;&nbsp;_}_  
&nbsp;&nbsp;&nbsp;},  
&nbsp;&nbsp;&nbsp;"aggs"...

Additional **"pattern"** element stops parser with continuing with next aggregation.

The DSL that I'm expecting and is working for me is the following:

"aggs": {  
"catpaths": {  
"terms": {  
"field": "categories.categoryPath",  
_"include": "(/[^/]+){2}"_  
},  
"aggs"...

Extra "pattern" element is really problematic in nested aggregation. It only works if it's included in the last aggregate element.

---

<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, 2017, 11:09pm UTC](https://discuss.elastic.co/t/nest-driver-is-adding-extra-pattern-element-to-include/79658/2 "2017-04-19T23:09:42Z")

</div>

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