Ejemplo n.º 1
0
 public void CheckSource(string sourceName, bool recreate = false)
 {
     try
     {
         ElasticIndexValidator.ValidateIndex(sourceName);
     }
     catch (InvalidElasticIndexException e)
     {
         if (recreate)
         {
             elasticClient.Indices.Create(sourceName, i => i.Map <TModel>(x => x.AutoMap()));
             // Todo Custom mapping
         }
         else
         {
             throw e;
         }
     }
 }
Ejemplo n.º 2
0
 private void CheckIndex(string indexName, bool recreate)
 {
     try
     {
         ElasticIndexValidator.ValidateIndex(indexName);
     }
     catch (InvalidElasticIndexException e)
     {
         if (recreate)
         {
             elasticClient.Indices.Delete(indexName);
             elasticClient.Indices.Create(indexName, i => i.Map <TModel>(x => x.AutoMap()));
             // Todo Custom mapping
         }
         else
         {
             throw e;
         }
     }
 }