elasticsearch - Nest is not Auto mapping not analized field -
i created mapped entity:
[elasticsearchtype(name = "cases")] public class case { [string(name = "case_name")] public string casename { get; set; } [string(name = "md5", index = fieldindexoption.notanalyzed)] public string md5 { get; set; } }
and then:
client.map<case>(mp => mp.automap());
but not including index type md5 field mapping:
get _mapping { "myindex": { "mappings": { "cases": { "properties": { "case_name": { "type": "string" }, "md5": { "type": "string" } } } } } }
what missing?
your code works me when running against newly created index
void main() { var pool = new singlenodeconnectionpool(new uri("http://localhost:9200")); var defaultindex = "default-index"; var connectionsettings = new connectionsettings(pool) .defaultindex(defaultindex) .prettyjson() .disabledirectstreaming() .onrequestcompleted(response => { // log out request if (response.requestbodyinbytes != null) { console.writeline( $"{response.httpmethod} {response.uri} \n" + $"{encoding.utf8.getstring(response.requestbodyinbytes)}"); } else { console.writeline($"{response.httpmethod} {response.uri}"); } console.writeline(); // log out response if (response.responsebodyinbytes != null) { console.writeline($"status: {response.httpstatuscode}\n\n" + $"{encoding.utf8.getstring(response.responsebodyinbytes)}\n" + $"{new string('-', 30)}\n"); } else { console.writeline($"status: {response.httpstatuscode}\n" + $"{new string('-', 30)}\n"); } }); var client = new elasticclient(connectionsettings); if (client.indexexists(defaultindex).exists) client.deleteindex(defaultindex); client.createindex(defaultindex); client.map<case>(mp => mp.automap()); client.getmapping<case>(); } [elasticsearchtype(name = "cases")] public class case { [string(name = "case_name")] public string casename { get; set; } [string(name = "md5", index = fieldindexoption.notanalyzed)] public string md5 { get; set; } }
yields following in console
head http://localhost:9200/default-index?pretty=true status: 200 ------------------------------ delete http://localhost:9200/default-index?pretty=true status: 200 { "acknowledged" : true } ------------------------------ put http://localhost:9200/default-index?pretty=true {} status: 200 { "acknowledged" : true } ------------------------------ put http://localhost:9200/default-index/cases/_mapping?pretty=true { "properties": { "case_name": { "type": "string" }, "md5": { "type": "string", "index": "not_analyzed" } } } status: 200 { "acknowledged" : true } ------------------------------ http://localhost:9200/default-index/_mapping/cases?pretty=true status: 200 { "default-index" : { "mappings" : { "cases" : { "properties" : { "case_name" : { "type" : "string" }, "md5" : { "type" : "string", "index" : "not_analyzed" } } } } } } ------------------------------