Hi,
I use a repository to deal with Elasticsearch CRUD operations. It works but I face a problem :
when I add fields to an existing index I don't know how to apply custom Index Descriptor. It works with an AutoMap but if I need any kind of custom how should I do ?
public ElasticSearchRepository(IElasticClient elasticClient, string index, Func<CreateIndexDescriptor, ICreateIndexRequest> indexDescriptor)
{
_elasticClient = elasticClient;
_index = index.ToLower();
var exist = _elasticClient.Indices.Exists(_index);
if (!exist.Exists)
{
var res = _elasticClient.Indices.Create(_index, indexDescriptor);
if (!res.IsValid)
throw res.OriginalException;
}
else
{
// Try to apply potential added mappings
var mapResponse = _elasticClient.Map<T>(x => x.Index(_index).AutoMap()); // <==== here I can apply AutoMap, but how to use my custom indexDescriptor ???
if (!mapResponse.IsValid)
throw mapResponse.OriginalException;
}
Thank you!