Created
October 2, 2013 10:11
-
-
Save ThomasArdal/6791576 to your computer and use it in GitHub Desktop.
Example of doing faceted search using ElasticSearch and 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
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