Skip to content

Instantly share code, notes, and snippets.

@alkampfergit
Last active August 29, 2015 14:12
Show Gist options
  • Save alkampfergit/19cc4314874c4f754b59 to your computer and use it in GitHub Desktop.
Save alkampfergit/19cc4314874c4f754b59 to your computer and use it in GitHub Desktop.
Regex Filter aggregation with NEST
.....
//this filters result of the query, then apply aggregations on terms.
//if you want to filter result of the aggregation you will need reducers
//https://github.com/elasticsearch/elasticsearch/issues/8110
.Aggregations(a1 => a1
.Filter("filter", fd => fd.Filter(f =>
f.Regexp(f3 => f3
.OnField(d => d.MdFacets)
.Value(parameters.FacetName + @"\|.*"))
)
.Aggregations(a2 => a2
.Terms("mdFacets", st => st
.Field(x => x.MdFacets)
.Size(9999)
)
)
)
);
var filter = result.Aggs.Filter("filter");
var metadataFacets = filter.Terms("mdFacets").Items........ ;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment