My issue is that when I call .Search(...) the result it returns have all null values set for all the fields (even though the fields have valid data).
MyClass is:
public class Member {
public string ID { get; set; }
public string ClientID { get; set; }
public string FirstName { get; set; }
public string LastName { get; set; }
public string EmailAddress { get; set; }
public string PasswordHash { get; set; }
public string[] UserRoleIDs { get; set; }
}
I construct the Elastic Client as such:
var node = new Uri("<correct url here>");
var config = new ConnectionSettings(node);
config.BasicAuthentication("elastic", "<correct password here>");
config.DisableDirectStreaming(true);
DB = new ElasticClient(config);
I query Elastic as such:
var res = DB.Search<Member>(s => s
.Index("members")
.Skip(0)
.Take(10)
.Query(q => q
.Term(t => t.EmailAddress, emailAddress)
)
);
The results I get are that the result is 200 OK, there are Hits and Documents, both of which have the correct ID's of the records I am searching for (the query is succeeding as expected).
I can also evaluate the res.ApiCall.ResponseBodyInBytes as a string and I can see the JSON that elastic is returning is correct (the fields have data).
BUT.. res.Document.FirstOrDefault() returns a "Member" class where all the fields are NULL (to stress, the JSON has values for the fields that are null).
I tried to change it to use Dictionary instead of my Member object and that seems to work correctly (E.g. myDictionary["FirstName"] == "Dan").
Also, I tried taking the ID the search result gives me and calling:
var user = DB.Get<Member>(id, i => i.Index("members"));
This has the same end result, all the fields of user.Hit are null :(