Hello,
i am facing issue while getting data from elasticsearch. i am using NEST client version 7.3.
i have my data stored in elasticsearch in following format:
{
"_index": "custom-index-dev",
"_type": "logevent",
"_id": "VJcPBm0BVa5zJPTZuwbI",
"_version": 1,
"_score": 0,
"_source": {
"@timestamp": "2019-09-06T15:42:35.4110845+05:30",
"level": "Information",
"messageTemplate": "{HostingRequestStartingLog:l}",
"message": "Request starting HTTP/1.1 POST http://localhost:5050/req/negotiate 0",
"fields": {
"Protocol": "HTTP/1.1",
"Method": "POST",
"Scheme": "http",
"Host": "localhost:5050",
"EventId": {
"Id": 1
},
"RequestId": "0HLPIMAUEFD65:00000001",
"RequestPath": "/req/negotiate",
"ConnectionId": "0HLPIMAUEFD65",
"Application": "Test"
},
"renderings": {
"HostingRequestStartingLog": [
{
"Format": "l",
"Rendering": "Request starting HTTP/1.1 POST http://localhost:5050/req/negotiate 0"
}
]
}
},
"fields": {
"@timestamp": [
"2019-09-06T10:12:35.411Z"
]
}
}
And i am accessing the same data in .Net Core using NEST client as below
var node = new Uri("http://localhost:9200");
var settings = new ConnectionSettings(node);
settings.DefaultIndex("custom-index-dev");
var client = new ElasticClient(settings);
var searchResponse = await client.SearchAsync<SearchResponse>(s => s
.From(0)
.Size(50)
);
And "SearchResponse" Model is a nested model which has Fields model init.
public class SearchResponse
{
public string Level { get; set; }
public DateTime Time { get; set; }
public string MessageTemplate { get; set; }
public Fields Fields { get; set; }
}
public class Fields
{
public EventId EventId { get; set; }
public string Host { get; set; }
public string TransportConnectionId { get; set; }
public string RequestId { get; set; }
public string RequestPath { get; set; }
public string ConnectionId { get; set; }
public string Application { get; set; }
}
public class EventId
{
public int Id { get; set; }
}
But i am not able to get fields data int my inner model. Though i am able to get data in "SearchResponse" model but not in "Fields" Model init.
Please suggest..
Thanks in anticipation