Skip to content

Instantly share code, notes, and snippets.

@ThomasArdal
Created October 2, 2013 10:11
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • 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