Reputation: 519
I have a controller that contains a method to retrieve data based off it's ID using NEST. On the CLI of Kibana, I grab the ID that it is displayed and paste that into the swagger web app to see if it will populate but it does not (returns a 204).
Swagger (asp.net core web api)
In my GET method I first attempted it by using SearchAsync but it did not work, so I switched over to GetAsync but still not getting it to work. Not sure why this is not working if in my model class I have all the properties created to match the _source
in line 22 in the CLI screenshot. Does anyone have any reason behind why it is not returning what I need it to do and just displaying a 204?
[HttpGet("{id}")]
public async Task<EsSource> Get(String id)
{
/* var response = await _elasticClient.SearchAsync<EsSource>(s => s
.Index("elastic-search-app-logs*")
.Query(q => q.Match(m => m.Field(f => f.TimeStamp).Query(id))));*/
var response = await _elasticClient.GetAsync<EsSource>(new DocumentPath<EsSource>(
new Id(id)), x => x.Index("elastic-search-app-logs*"));
return response?.Source;
}
My models class
namespace ESPractice.Models
{
public class EsSource
{
public String TimeStamp { get; set; }
public String Level { get; set; }
public String MessageTemplate { get; set; }
public String Message { get; set; }
}
public class EsExceptions
{
public String Depth { get; set; }
public String ClassName { get; set; }
public String Message { get; set; }
public String Source { get; set; }
public String StackTraceString { get; set; }
public String RemoteStackTraceString { get; set; }
public String RemoteStackIndex { get; set; }
public String HResult { get; set; }
public String HelpURL { get; set; }
}
public class EsFields
{
public String SourceContext { get; set; }
public String ActionId { get; set; }
public String ActionName { get; set; }
public String RequestId { get; set; }
public String RequestPath { get; set; }
public String ConnectionId { get; set; }
public String MachineName { get; set; }
public String Environment { get; set; }
}
}
Upvotes: 1
Views: 676
Reputation: 9979
You can simply your call with await _client.GetAsync<EsSource>(id, x => x.Index("elastic-search-app-logs*"));
You can also enable debug so you will receive detailed information about what was sent to elasticsearch and what was the response as described here.
If you want to debug a single call you can do (make sure it's not enabled for production)
var response = client.Search<Project>(s => s
.RequestConfiguration(r => r
.DisableDirectStreaming()
)
.Query(q => q
.MatchAll()
)
);
Check response.DebugInformation
for more details.
Upvotes: 1