/// <summary> /// NEST Backwards compatibility /// </summary> public static MappingsDescriptor AddMapping <T>(this MappingsDescriptor mapping, TypeName typeName, Func <TypeMappingDescriptor <T>, ITypeMapping> map) where T : class { var item = mapping.Map(typeName, map); return(mapping); }
protected override IPromise <IMappings> ApplyAggregateMappingsOnIndex(MappingsDescriptor md) { return(md.Map <Favorites>(tm => tm .Properties(prop => prop .Keyword(x => x.Name(nameof(Version))) .Date(x => x.Name(nameof(AggregateSnapshot <Favorites, FavoritesId> .RequestTimestamp))) .Keyword(x => x.Name(n => n.ObjectType)) .Keyword(x => x.Name(n => n.FavoritedBy))))); }
protected override IPromise <IMappings> ApplyAggregateMappingsOnIndex(MappingsDescriptor md) { return(md.Map <PublicScheme>(tm => tm .Properties(prop => prop .Keyword(x => x.Name(nameof(Version))) .Date(x => x.Name(nameof(AggregateSnapshot <PublicScheme, PublicSchemeId> .RequestTimestamp))) .Keyword(x => x.Name(n => n.PublisherId)) .Keyword(x => x.Name(n => n.Description)) .Object <ColorScheme>(cs => cs .Name(x => x.ColorScheme) .AutoMap() .Properties(eProp => eProp .Keyword(x => x.Name(n => n.colorSchemeId)) .Keyword(x => x.Name(n => n.colorSchemeName))))))); }
public static void TestPage_Type_Mapping_Should_Create_Index_And_Return_IsValid() { var elasticClient = new ElasticClient(new Uri("http://localhost:9200")); var helper = new TypeScanIndexableTypeMapperResolver(); var indexableTypeMappers = helper.GetAll().ToList(); var typeMapper = indexableTypeMappers.First(); var typeMapping = typeMapper.CreateTypeMapping(new CultureInfo("en")); var typeName = typeMapper.TypeName; var mappingsDescriptor = new MappingsDescriptor(); mappingsDescriptor.Map<IIndexablePageData>(typeName, x => typeMapping); var createIndexResponse = elasticClient.CreateIndex("site_en_1", x => x.Mappings(m => mappingsDescriptor)); Assert.Equal(true, createIndexResponse.IsValid); Assert.Equal(true, createIndexResponse.Acknowledged); }
#pragma warning restore 618 #pragma warning disable 618 public static ITypeMapping ProjectMappings(MappingsDescriptor map) => map .Map <Project>(ProjectTypeMappings);
/// <summary> /// /// </summary> /// <returns></returns> public async Task Reindex(bool refreshAllIndex, string refreshIndex, string companyId) { var userName = _httpContextAccessor.HttpContext.User.Claims.FirstOrDefault(s => s.Type == "userName")?.Value; if (userName == "*****@*****.**") { if (refreshAllIndex) { foreach (var item in GetTypes()) { await DeleteIndexES(item.Key); } } if (!string.IsNullOrEmpty(refreshIndex)) { await DeleteIndexES(refreshIndex); } var analyzers = new AnalysisDescriptor().Analyzers(aa => aa .Custom("folding", sa => sa.Tokenizer("standard").Filters("lowercase", "asciifolding").CharFilters("html_strip")) .Custom("sortable", sa => sa.Tokenizer("keyword").Filters("lowercase", "asciifolding")) .Custom("uax", sa => sa.Tokenizer("uax_url_email").Filters("lowercase", "stop")) ); var mappingDescriptor = new MappingsDescriptor(); foreach (var item in GetTypes()) { if (!_esClient.IndexExists(item.Key).Exists) { switch (item.Key) { case "activity_history_leads": mappingDescriptor = mappingDescriptor.Map <ActivityHistoryLead>(mm => mm .Properties(p => p .Text(t => t.Name(n => n.CreatedBy).Analyzer("uax").SearchAnalyzer("uax")) ) ); break; case "chat_leads": mappingDescriptor = mappingDescriptor.Map <ChatLead>(mm => mm .Properties(p => p .Text(t => t.Name(n => n.CreatedBy).Analyzer("uax").SearchAnalyzer("uax")) ) ); break; case "companies": mappingDescriptor = mappingDescriptor.Map <Company>(mm => mm .Properties(p => p .Text(t => t.Name(n => n.CompanyName).Analyzer("folding").SearchAnalyzer("folding")) .Text(t => t.Name(n => n.Email).Analyzer("uax").SearchAnalyzer("uax")) .Text(t => t.Name(n => n.CreatedBy).Analyzer("uax").SearchAnalyzer("uax")) .Text(t => t.Name(n => n.UpdatedBy).Analyzer("uax").SearchAnalyzer("uax")) ) ); break; case "contact_leads": mappingDescriptor = mappingDescriptor.Map <ContactLead>(mm => mm .Properties(p => p .Text(t => t.Name(n => n.Name).Analyzer("folding").SearchAnalyzer("folding")) .Text(t => t.Name(n => n.Email).Analyzer("uax").SearchAnalyzer("uax")) .Text(t => t.Name(n => n.CreatedBy).Analyzer("uax").SearchAnalyzer("uax")) .Text(t => t.Name(n => n.UpdatedBy).Analyzer("uax").SearchAnalyzer("uax")) ) ); break; case "common_data": mappingDescriptor = mappingDescriptor.Map <CommonData>(mm => mm .Properties(p => p .Text(t => t.Name(n => n.CreatedBy).Analyzer("uax").SearchAnalyzer("uax")) .Text(t => t.Name(n => n.UpdatedBy).Analyzer("uax").SearchAnalyzer("uax")) ) ); break; case "leads": mappingDescriptor = mappingDescriptor.Map <Lead>(mm => mm .Properties(p => p .Text(t => t.Name(n => n.FullName).Analyzer("folding").SearchAnalyzer("folding")) .Text(t => t.Name(n => n.Email).Analyzer("uax").SearchAnalyzer("uax")) .Text(t => t.Name(n => n.CreatedBy).Analyzer("uax").SearchAnalyzer("uax")) .Text(t => t.Name(n => n.UpdatedBy).Analyzer("uax").SearchAnalyzer("uax")) ) ); break; case "product_categories": mappingDescriptor = mappingDescriptor.Map <ProductCategory>(mm => mm .Properties(p => p .Text(t => t.Name(n => n.Name).Analyzer("folding").SearchAnalyzer("folding")) .Text(t => t.Name(n => n.CreatedBy).Analyzer("uax").SearchAnalyzer("uax")) .Text(t => t.Name(n => n.UpdatedBy).Analyzer("uax").SearchAnalyzer("uax")) ) ); break; case "products": mappingDescriptor = mappingDescriptor.Map <Product>(mm => mm .Properties(p => p .Text(t => t.Name(n => n.Name).Analyzer("folding").SearchAnalyzer("folding")) .Text(t => t.Name(n => n.CreatedBy).Analyzer("uax").SearchAnalyzer("uax")) .Text(t => t.Name(n => n.UpdatedBy).Analyzer("uax").SearchAnalyzer("uax")) ) ); break; case "teams": mappingDescriptor = mappingDescriptor.Map <Team>(mm => mm .Properties(p => p .Text(t => t.Name(n => n.Name).Analyzer("folding").SearchAnalyzer("folding")) .Text(t => t.Name(n => n.CreatedBy).Analyzer("uax").SearchAnalyzer("uax")) .Text(t => t.Name(n => n.UpdatedBy).Analyzer("uax").SearchAnalyzer("uax")) ) ); break; case "team_users": mappingDescriptor = mappingDescriptor.Map <TeamUsers>(mm => mm .Properties(p => p .Text(t => t.Name(n => n.CreatedBy).Analyzer("uax").SearchAnalyzer("uax")) .Text(t => t.Name(n => n.UpdatedBy).Analyzer("uax").SearchAnalyzer("uax")) ) ); break; case "access_rights": mappingDescriptor = mappingDescriptor.Map <AccessRight>(mm => mm .Properties(p => p .Text(t => t.Name(n => n.CreatedBy).Analyzer("uax").SearchAnalyzer("uax")) .Text(t => t.Name(n => n.UpdatedBy).Analyzer("uax").SearchAnalyzer("uax")) ) ); break; } await _esClient.CreateIndexAsync(item.Key, c => c .Settings(s => s.Analysis(a => analyzers)) .Mappings(m => mappingDescriptor ) ); await Migrate(item.Key, companyId); } } } }
public static IPromise <IMappings> UserAccountIndexMappings(MappingsDescriptor ms) { return(ms.Map <UserAccount>(m => m.AutoMap(-1))); }
public static IPromise <IMappings> RepoSettingsIndexMappings(MappingsDescriptor ms) { return(ms.Map <RepoSettings>(m => m.AutoMap(-1))); }
public static IPromise <IMappings> JobsIndexMappings(MappingsDescriptor ms) { return(ms.Map <JobInfo>(m => m.AutoMap(-1))); }
public virtual MappingsDescriptor ConfigureIndexMappings(MappingsDescriptor mappings) { return(mappings.Map <T>(Name, BuildMapping)); }
protected virtual MappingsDescriptor CreateMappingsDescriptor(CultureInfo language) { var mappingsDescriptor = new MappingsDescriptor(); foreach (var indexableTypeMapper in _indexableTypeMapperResolver.GetAll()) { var typeMapping = indexableTypeMapper.CreateTypeMapping(language); mappingsDescriptor.Map<IIndexablePageData>(indexableTypeMapper.TypeName, x => typeMapping); } return mappingsDescriptor; }