How to write date range query in Nest ElasticSearch client?
Looking at the source code, there are two overloads of the OnField method. When I use the the that takes Linq expression parameter, the query does not return any data. But I was able to make it work with the other overload, which takes string value, where I am passing the field name of the elasticsearch document as a string. Here's the query that returns expected results:
var resultSet = _elasticSearchClient.Search<Amqp>(q => q.Query (p => p.Range(v => v.OnField("LogGenerationTime").GreaterOrEquals(lowerBound))).Size(10000));
Looks like a bug in the framework but am not completely sure.
The following code works for me:
Range(r => r.GreaterOrEquals(lowerBound).Format("MM/dd/yyyy").OnField(LogTime))