Last active
August 29, 2015 14:12
-
-
Save alkampfergit/19cc4314874c4f754b59 to your computer and use it in GitHub Desktop.
Regex Filter aggregation with NEST
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
..... | |
//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