Elasticsearch mapping without C# POCO classes -
in our project using c# poco classes map fields in elasticsearch. use nest library. our project growing , continuously adding new properties , new data models, painful update c# poco classes in several places uptake new changes. have data in json format use data validation , other processing. looking forward use json data , index, update, search, etc without having provide c# poco classes. can point me how achieve this? appreciate help. let me know if more information needed.
this have today. (small example)
c# poco class:
public class testdatamodel { public int id { get; set; } public string value { get; set; } public datetime? datetimefield { get; set; } }
}
elastic custom helper method:
public async task<iindexresponse> indexasync<t>(t data, string indexname, string typename, long versionnumber) t : class { if (indexname == null) { throw new argumentnullexception("index name null. please provide index name insert data."); } return await client.indexasync(data, => .index(indexname) .type(typename) .version(versionnumber)); }
usage:
iindexresponse response = await searchhelper.indexasync<testdatamodel>(data.toobject<testdatamodel>(), indexname, elastictype);
the data in above line in json format.
Comments
Post a Comment