I have upgraded my Elasticsearch v7 and installed the new Nest Nuget packages in dev studio but once I changed my code so it worked with Nest v7 the queries no longer return any hits.
string url = "http://localhost:9200";
var uri = new Uri(url);
var settings = new ConnectionSettings(uri);
try
{
settings.ThrowExceptions(alwaysThrow: true);
settings.PrettyJson();
Client = new ElasticClient(settings);
var response = Client.Cluster.Health();
elasticSearchStatusLabel.Text = response.Status.ToString();
settings.DefaultIndex("auditlog");
}
catch (Exception excp)
{
MessageBox.Show("Error Connecting to Elastic Search" + Environment.NewLine + Environment.NewLine +
"Exception: " + excp.Message, "Error Connecting", MessageBoxButtons.OK, MessageBoxIcon.Warning);
}
List<AuditRecord> resultsList = new List<AuditRecord>();
try
{
resultsList = Client.SearchAsync<AuditRecord>(s => s
.From(0)
.Take(100)
.Query(qry => qry
.MatchAll()
)
).Result.Documents.ToList();
}
catch
{
resultsList = null;
}
This use to load in to this class....
public class AuditRecord
{
public string audit_Id { get; set; }
public string audit_UserId { get; set; }
public string audit_TimeStamp { get; set; }
public string audit_Event { get; set; }
public string audit_Application { get; set; }
public string audit_Action { get; set; }
}
The code doesn't error but also doesn't return any values. If the following query is run in Kibana then results are found.
GET auditlog/_search
{
"query" : {
"match_all": {}
}
}
Any help would be appreciated.