使用Elasticsearch 2.x如何将DateTime变量传递给DateHistogram的ExtendedBounds方法?

时间:2016-04-18 13:11:29

标签: elasticsearch nest

Nest版本2.1.1,Elasticsearch.Net版本2.1.1 Elasticsearch版本2.3.0

当我使用Elastic search 1.3.4时,我可以将字符串传递给我的DateHistogram的ExtendedBounds方法,因为升级到2.3.0虽然我只能选择传递日期。很好,我想但在运行时我得到这个错误: '时间表达'月'字符串无效。如果我格式化我的DateTime变量,它们显然是该方法不接受的字符串。

我的简化查询是:

DateTime startDate = new DateTime(2015, 4, 1);                 //31/04/2015 00:00:00
DateTime endDate = new DateTime(2015 + 1, 4, 1).AddDays(-1);   // 31/03/2015 00:00:00

Query(Query => q..
         ..
         .DateHistogram("my_group", h => h.Field("my_fieldName")
             .Interval("month")
             .MinimumDocumentCount(0)
             .ExtendedBounds(startDate, endDate)

0 个答案:

没有答案