I'm experimenting with creating an index but using the strongly typed classes.
The basic desire is being able to specify an index WITHOUT using C# POCO document class. A tall order I realize since I can't use Mapping Attributes or Fluent Mapping or the POCO via the AutoMapper.
The problem that I'm running into is how to create a TypeMapping object successfully so that I can set it's properties and marry it to a TypeName object.
The code below does create an index (good thing) but I can't seem to figure out how to instantiate a TypeName object (bad thing). I know I'm being dense but I'm having a helluva time since the documentation doesn't actually address using these strongly typed classes at all (or I haven't found the doc pages yet).
Any help would be appreciated.
C# Code that I'm using:
var settings = new IndexSettings();
settings.NumberOfReplicas = 0;
settings.NumberOfShards = 2;
var indexConfig = new IndexState
{
Settings = settings
};
var indexMappings = new Mappings();
var aType = new TypeName();
aType.Name = "Index Column Name;
aType.Type = typeof(string);
// A basic object but has nothing defined in it and I haven't found how to hydrate one up via a factory.
var aTypeMapping = new TypeMapping();
indexMappings.Add(aType, aTypeMapping);
var indexCreateRequest = new CreateIndexRequest(CurrentIndexName, indexConfig);
indexCreateRequest.Mappings = indexMappings;
var aResponse = Client.CreateIndex(indexCreateRequest);
And the index that's created:
{
"dynamicindex-28-09-2017-19-26-14": {
"aliases": {
"dynamicindex": {}
},
"mappings": {
"FirstName": {},
"Email": {},
"LastName": {},
"Age": {}
},
"settings": {
"index": {
"creation_date": "1506626774660",
"number_of_shards": "2",
"number_of_replicas": "0",
"uuid": "rVNvrRcJQrmTxfV7JDczXA",
"version": {
"created": "5060199"
},
"provided_name": "dynamicindex-28-09-2017-19-26-14"
}
}
}
}