Skip to content

Instantly share code, notes, and snippets.

@ThomasArdal
Created October 2, 2013 10:11
Show Gist options
  • Save ThomasArdal/6791576 to your computer and use it in GitHub Desktop.
Save ThomasArdal/6791576 to your computer and use it in GitHub Desktop.
Example of doing faceted search using ElasticSearch and NEST
var result = elasticClient.Search<ErrorDocument>(s => s
.FacetDateHistogram(fd => fd
.OnField(p => p.Time)
.Interval(DateInterval.Day)
.Global()
.FacetFilter(ff => ff
.Range(rf => rf
.From(DateTime.UtcNow.AddDays(-14))
.To(DateTime.UtcNow)
)
)
)
);
var facetBucket = result.Facet<DateHistogramFacet>(p => p.Time);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment