c# - How to write date range query in Nest ElasticSearch client? -
c# - How to write date range query in Nest ElasticSearch client? -
i have .net application trying fetch info elasticsearch document store, having records in next structure:
{ "_index": "testindex", "_type": "amqp", "_id": "123", "_source": { "@timestamp": "2014-10-27t01:31:54.780z", "type": "amqp", "loggenerationtime": "2014-10-26t21:31:54.780", "threadid": "6", "processid": "8136", "sessionid": "xyz", "userid": "12345678", }, }
i want fetch records loggenerationtime in lastly 20 mins. here's query have written far not seem homecoming data:
var format = "yyyy-mm-dd't'hh:mm:ss.fff"; var lowerbound = datetime.now.addminutes(-20); isearchresponse<amqp> resultset = _elasticsearchclient.search<amqp>(q => q.query (p => p.range (v => v.onfield (x => x.loggenerationtime).greaterorequals(lowerbound, format))));
can please help write right query fetch expected results? thanks!
looking @ source code, there 2 overloads of onfield method. when utilize the takes linq look parameter, query not homecoming data. able create work other overload, takes string value, passing field name of elasticsearch document string. here's query returns expected results:
var resultset = _elasticsearchclient.search<amqp>(q => q.query (p => p.range(v => v.onfield("loggenerationtime").greaterorequals(lowerbound))).size(10000));
looks bug in framework not sure.
c# .net lambda elasticsearch nest
Comments
Post a Comment