Example #1
0
        /// <summary>
        /// Reindex constructor. The class reuires a index and a type for the old index and also the new index. The old index can then be converteds or reindexed to the new index.
        /// </summary>
        /// <param name="oldIndexTypeDescription">index and index type parameters for the old index</param>
        /// <param name="newIndexTypeDescription">index and index type parameters for the new index</param>
        /// <param name="connectionString">Elasticsearch connection string</param>
        public ElasticsearchCrudReindex(IndexTypeDescription oldIndexTypeDescription, IndexTypeDescription newIndexTypeDescription, string connectionString)
        {
            _oldIndexTypeDescription = oldIndexTypeDescription;
            _newIndexTypeDescription = newIndexTypeDescription;
            IElasticsearchMappingResolver elasticsearchMappingResolver = new ElasticsearchMappingResolver();

            elasticsearchMappingResolver.AddElasticSearchMappingForEntityType(typeof(TNew), MappingUtils.GetElasticsearchMapping <TNew>(newIndexTypeDescription));
            elasticsearchMappingResolver.AddElasticSearchMappingForEntityType(typeof(TOld), MappingUtils.GetElasticsearchMapping <TOld>(oldIndexTypeDescription));
            _context = new ElasticsearchContext(connectionString, elasticsearchMappingResolver);
        }
 public static ElasticsearchMapping GetElasticsearchMapping <T>(IndexTypeDescription indexTypeDescription)
 {
     return(new IndexTypeMapping(indexTypeDescription.Index, indexTypeDescription.IndexType, typeof(T)));
 }