public async Task <bool> Initialize() { await _client.CreateIndexAsync(typeof(Basket.Models.BasketIndex).FullName.ToLower(), i => i .Settings(s => s .NumberOfShards(3) .TotalShardsPerNode(3) .NumberOfReplicas(0) .Analysis(analysis => analysis.AutoCompleteAnalyzers()) ) .Mappings(mappings => mappings.Map <Basket.Models.BasketIndex>(map => map.Properties(props => props.Keyword(s => s.Name(x => x.Id).IgnoreAbove(256)) .Keyword(s => s.Name(x => x.CustomerId).IgnoreAbove(256)) .Text(s => s.Name(x => x.Customer).Fields(x => x.AutoCompleteFields())) .Number(s => s.Name(x => x.TotalItems).Type(NumberType.Long)) .Number(s => s.Name(x => x.TotalQuantity).Type(NumberType.Long)) .Number(s => s.Name(x => x.SubTotal).Type(NumberType.Long)) .Date(s => s.Name(x => x.Created).Format("epoch_millis")) .Date(s => s.Name(x => x.Updated).Format("epoch_millis")) )))).ConfigureAwait(false); await _client.CreateIndexAsync(typeof(Basket.Entities.Item.Models.BasketItemIndex).FullName.ToLower(), i => i .Settings(s => s .NumberOfShards(3) .TotalShardsPerNode(3) .NumberOfReplicas(0) .Analysis(analysis => analysis.AutoCompleteAnalyzers()) ) .Mappings(mappings => mappings.Map <Basket.Entities.Item.Models.BasketItemIndex>(map => map.Properties(props => props.Keyword(s => s.Name(x => x.Id).IgnoreAbove(256)) .Keyword(s => s.Name(x => x.BasketId).IgnoreAbove(256)) .Keyword(s => s.Name(x => x.ProductId).IgnoreAbove(256)) .Binary(s => s.Name(x => x.ProductPictureContents)) .Keyword(s => s.Name(x => x.ProductPictureContentType).IgnoreAbove(256)) .Text(s => s.Name(x => x.ProductName).Fields(x => x.AutoCompleteFields())) .Text(s => s.Name(x => x.ProductDescription).Fields(x => x.AutoCompleteFields())) .Number(s => s.Name(x => x.ProductPrice).Type(NumberType.Long)) .Number(s => s.Name(x => x.Quantity).Type(NumberType.Long)) .Number(s => s.Name(x => x.SubTotal).Type(NumberType.Long)) )))).ConfigureAwait(false); await _client.CreateIndexAsync(typeof(Basket.Services.BasketsUsingProductHandler.ProductBaskets).FullName.ToLower(), i => i .Settings(s => s .NumberOfShards(3) .TotalShardsPerNode(3) .NumberOfReplicas(0) .Analysis(analysis => analysis.AutoCompleteAnalyzers()) ) .Mappings(mappings => mappings.Map <Basket.Services.BasketsUsingProductHandler.ProductBaskets>(map => map.Properties(props => props.Keyword(s => s.Name(x => x.Id).IgnoreAbove(256)) .Keyword(s => s.Name(x => x.Baskets).IgnoreAbove(256)) )))).ConfigureAwait(false); this.Done = true; return(true); }
private Task CreateHighwaysIndex(string highwaysIndexName) { return(_elasticClient.CreateIndexAsync(highwaysIndexName, c => c.Mappings( ms => ms.Map <Feature>(m => m.Properties(ps => ps.GeoShape(g => g.Name(f => f.Geometry) .Tree(GeoTree.Geohash) .TreeLevels(10) .DistanceErrorPercentage(0.2))) ) ) )); }
public async Task CreateAsync() { var indexName = await m_ElasticClient.GetNextIndexNameByAliasAsync(Settings.Alias); var createResponse = await m_ElasticClient.CreateIndexAsync( indexName, mappings : new MappingsDescriptor().Map <Job>(m => m .Properties(p => p .String(s => s .NotAnalyzed() .Name(j => j.Id))) .Properties(p => p .String(s => s .Analyzer("ik") .SearchAnalyzer("ik_smart") .Name(j => j.Name))) .Properties(p => p .Number(n => n .Name(j => j.Type))) .Properties(p => p .String(s => s .NotAnalyzed() .Name(j => j.Contact))))); if (createResponse.Acknowledged) { await m_ElasticClient.SwapAliasAsync(Settings.Alias, indexName); } }
private static void LoadMovies(IElasticClient elasticClient, string indexName) { var settingsResponse = elasticClient.GetIndexSettingsAsync(x => x.Index(indexName)).Result; if (settingsResponse.ServerError?.Status == 404) { var response = elasticClient.CreateIndexAsync(indexName, d => d .Mappings(ms => ms .Map <MovieSearchItem>(m => m.AutoMap()) ) ).Result; if (response.IsValid == false) { throw new Exception(string.Format("{0}: {1}", response.ServerError.Status, response.ServerError.Error), response.OriginalException); } } var movies = GetMovies().ToList(); foreach (var movie in movies) { elasticClient.Index(movie, i => i.Index(indexName)); } }
public async Task <IActionResult> CreateEsIndex() { try { var response = await _esClient.CreateIndexAsync("users", c => { return(c.Mappings(ms => { return ms.Map <AppUser>(m => { return m.AutoMap <UserProperty>().AutoMap <AppUser>(); }); })); }); //写入成功 if (response.IsValid) { return(Ok()); } } catch (Exception e) { throw; } return(BadRequest()); }
public async Task <CreateIndicesQueryResult> Handle(CreateIndicesQuery request, CancellationToken cancellationToken) { var createNoteIndexResponse = await _elasticClient.CreateIndexAsync(Constants.Constants.IndexNameNote, c => c .Mappings(ms => ms .Map <Note>(m => m.AutoMap()) ) ); var createAuthorIndexResponse = await _elasticClient.CreateIndexAsync(Constants.Constants.IndexNameAuthor, c => c .Mappings(ms => ms .Map <Author>(m => m.AutoMap()) ) ); return(new CreateIndicesQueryResult(createNoteIndexResponse.Acknowledged && createAuthorIndexResponse.Acknowledged)); }
public async Task CreateAsync(params IElasticsearchIndexContributor[] additionalContributors) { var contribCollection = new SortedSet <IElasticsearchIndexContributor>(_contributors); var indexName = _client.Infer.DefaultIndex; contribCollection.UnionWith(additionalContributors); indexName = PreIndexContribution(contribCollection.OfType <IElasticsearchIndexPreCreationContributor>(), indexName); try { var indexResponse = await _client.CreateIndexAsync(i => { i.Index(indexName); ContributeCore(i, contribCollection.OfType <IElasticsearchIndexCreationContributor>()); return(i); }); OnCompleted(contribCollection.OfType <IElasticsearchIndexCreationSuccessContributor>(), indexResponse); } catch (Exception ex) { OnError(contribCollection.OfType <IElasticsearchIndexCreationFailureContributor>(), ex); throw; } }
public async Task EnureIndexExistsAsync(string environmentName, IElasticClient client) { var type = typeof(T); var indexName = $"{environmentName.ToLower()}-{IndexName}"; await _mutex.WaitAsync(); try { if (!client.ConnectionSettings.DefaultIndices.TryGetValue(type, out var defaultIndexName) || indexName != defaultIndexName) { var response = await client.IndexExistsAsync(indexName).ConfigureAwait(false); if (!response.Exists) { await client.CreateIndexAsync(indexName, i => i .Mappings(ms => ms .Map <T>(m => { Map(m); return(m); }) ) ); } client.ConnectionSettings.DefaultIndices[type] = indexName; } } finally { _mutex.Release(); } }
private async Task SetupIndexAsync(IElasticClient connection, string indexName, string entityName, bool forceCreate) { var exists = Wrap(await connection.IndexExistsAsync(x => x.Index(indexName)).ConfigureAwait(false)).Exists; if (exists && forceCreate) { Wrap(await connection.DeleteIndexAsync(x => x.Index(indexName)).ConfigureAwait(false)); exists = false; } if (!exists) { var createResponse = Wrap(await connection.CreateIndexAsync(createIndexDescriptor => createIndexDescriptor .Index(indexName) .Analysis(a => a .Analyzers(x => x.Add("lowercaseKeyword", new CustomAnalyzer { Tokenizer = "keyword", Filter = new[] { "standard", "lowercase" } })) ) .AddMapping <TUser>(m => m .MapFromAttributes() .IncludeInAll(false) .IdField(x => x.Path("id")) .Type(entityName) ) ).ConfigureAwait(false)); AssertIndexCreateSuccess(createResponse); await SeedAsync().ConfigureAwait(false); } }
/// <summary> /// The create index API allows to instantiate an index. Elasticsearch provides support for multiple indices, /// including executing operations across several indices. /// <para> </para>http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/indices-create-index.html /// </summary> /// <param name="client"></param> /// <param name="index">The name of the index to be created</param> /// <param name="createIndexSelector">A descriptor that further describes the parameters for the create index operation</param> public static Task<IIndicesOperationResponse> CreateIndexAsync(this IElasticClient client, string index, Func<CreateIndexDescriptor, CreateIndexDescriptor> createIndexSelector = null) { index.ThrowIfNullOrEmpty("index"); createIndexSelector = createIndexSelector ?? (c => c); return client.CreateIndexAsync(c => createIndexSelector(c).Index(index)); }
private async Task CreateMapping <T>(IElasticClient client, Func <PutMappingDescriptor <T>, IPutMappingRequest> mapping) where T : class { if (!(await client.IndexExistsAsync(client.ConnectionSettings.DefaultIndex)).Exists) { await client.CreateIndexAsync(client.ConnectionSettings.DefaultIndex); await client.MapAsync <T>(mapping); } }
/// <summary> /// 创建索引 /// </summary> /// <typeparam name="TDocument">文档类型</typeparam> /// <param name="index">索引名称。注意:必须小写</param> /// <param name="alias">别名名称。注意:必须小写</param> /// <param name="cancellationToken">取消令牌</param> public async Task CreateIndexAsync <TDocument>(string index, string alias = null, CancellationToken cancellationToken = default) where TDocument : class { await _client.CreateIndexAsync <TDocument>(index, _options.NumberOfShards, _options.NumberOfReplicas, cancellationToken); if (alias.IsEmpty() == false) { await _client.Indices.PutAliasAsync(index, alias, ct : cancellationToken); } }
private async Task EnsureIndexesExist() { var existsResponse = await _elasticClient.IndexExistsAsync(PagesIndexName); if (!existsResponse.Exists) { await _elasticClient.CreateIndexAsync(PagesIndexName); } }
public async Task CreateIfNotExists(IndexDefinition searchIndexDefinition) { var indexName = searchIndexDefinition.ElasticIndexName(); var existsResponse = await _elasticClient.IndexExistsAsync(new IndexExistsRequest(indexName)); if (!existsResponse.Exists) { var mappings = searchIndexDefinition.CreateElasticMappings(); var createResponse = await _elasticClient.CreateIndexAsync(new CreateIndexRequest(searchIndexDefinition.ElasticIndexName()) { Mappings = mappings }); if (!createResponse.IsValid) { throw new Exception("Error creating index.", createResponse.OriginalException); } } }
/// <summary> /// Creates the default ElasticSearch index. /// </summary> public async Task <ICreateIndexResponse> CreateIndex() { if (!(await _client.IndexExistsAsync(_serviceConfig.IndexName)).Exists) { return(await _client.CreateIndexAsync(_serviceConfig.IndexName, cid => cid .Mappings(md => SearchConstants.Mappings(md)) )); } return(null); }
public async Task CreateIndex(IElasticClient elasticClient, string indexName) { if (!elasticClient.IndexExists(indexName).Exists) { await elasticClient.CreateIndexAsync(indexName, c => c.InitializeUsing(new IndexState { Settings = new IndexSettings { NumberOfReplicas = 1, NumberOfShards = 2 } })); } }
public async Task CreateAsync() { var newindexName = indexNameResolver.ResolveUniqueIndexName(UmbracoSearchFactory.ActiveIndexName); var result = await client.CreateIndexAsync(newindexName, WithCreateIndexDescriptorCore).ConfigureAwait(false); if (result.IsValid) { Parallel.ForEach(UmbracoSearchFactory.GetContentIndexServices(), c => c.UpdateIndexTypeMapping(newindexName)); Parallel.ForEach(UmbracoSearchFactory.GetMediaIndexServices(), c => c.UpdateIndexTypeMapping(newindexName)); } }
private async Task <ICreateIndexResponse> Create <TModel>(IElasticClient client, string indexName) where TModel : class { var response = await client.GetIndexAsync(indexName); if (!response.IsValid) { return(await client.CreateIndexAsync(indexName, c => c.Mappings(ms => ms.Map <TModel>(m => m.AutoMap())))); } else { return(null); } }
/// <summary> /// Create index Tv by date /// </summary> /// <param name="dateTime"></param> public async Task CreateIndexTvByDateAsync(DateTime dateTime, CancellationToken cancellationToken = default(CancellationToken)) { var keywordProperty = new PropertyName("keyword"); string index = $"xmltv-{dateTime.ToString("d")}"; if (!(await _elasticClient.IndexExistsAsync(index, cancellationToken: cancellationToken)).Exists) { var response = await _elasticClient.CreateIndexAsync(index, c => c .Mappings(x => x.Map <tv>(tv => tv.Properties(p => p.Object <tvChannel>(tvc => tvc.AutoMap()) .Object <tvProgramme>(tvp => tvp.AutoMap()) ))), cancellationToken : cancellationToken); } }
public async Task ReIndex <T>(IReadOnlyCollection <T> items) where T : class, IEntity { var exists = await _elasticClient.IndexExistsAsync(_indexName); if (exists.Exists) { await _elasticClient.DeleteIndexAsync(_indexName); await _elasticClient.CreateIndexAsync(_indexName); } await Task.WhenAll(items.Select(async item => await AddItem(item))); await _elasticClient.RefreshAsync(new RefreshRequest(_indexName)); }
/// <summary> /// 如果索引不存在就创建 /// </summary> /// <param name="client"></param> /// <param name="indexName"></param> /// <param name="selector"></param> /// <returns></returns> public static async Task CreateIndexIfNotExistsAsync(this IElasticClient client, string indexName, Func <CreateIndexDescriptor, ICreateIndexRequest> selector = null) { indexName = indexName.ToLower(); var exist_response = await client.IndexExistsAsync(indexName); exist_response.ThrowIfException(); if (exist_response.Exists) { return; } var response = await client.CreateIndexAsync(indexName, selector); response.ThrowIfException(); }
public async Task Start() { _client = new ElasticClient(_settings); var nodeInfo = await _client.NodesInfoAsync(); if (nodeInfo.Nodes.Values.Any(x => Convert.ToUInt32(x.Version.Split('.')[0]) < 6)) { throw new NotSupportedException("Elasticsearch verison 6 or greater is required"); } var exists = await _client.IndexExistsAsync(_indexName); if (!exists.Exists) { await _client.CreateIndexAsync(_indexName); } }
/// <summary> /// 初始化索引映射 /// </summary> /// <param name="client">ES客户端</param> /// <param name="indexName">索引名</param> public static async Task InitializeIndexMapAsync(this IElasticClient client, string indexName) { var newName = indexName + DateTime.Now.Ticks; var result = await client.CreateIndexAsync(newName, x => x.Index(newName) .Settings(o => o.NumberOfShards(1) .NumberOfReplicas(1) .Setting("max_result_window", int.MaxValue))); if (result.Acknowledged) { await client.AliasAsync(x => x.Add(o => o.Index(newName).Alias(indexName))); return; } throw new ElasticsearchException($"创建索引 {indexName} 失败:{result.ServerError.Error.Reason}"); }
private async Task CreateMappings(IElasticClient elasticClient, IndexName indexName, TypeName typeName) { var result = await elasticClient.IndexExistsAsync(indexName); if (!result.Exists) { ICreateIndexRequest createIndexRequest; switch (indexName.Name) { case "records": createIndexRequest = new CreateIndexDescriptor(indexName) .Mappings(s => s .Map(typeName, tm => tm .Properties(p => p.Keyword(k => k.Name("OwnedBy"))) .Properties(p => p.Keyword(k => k.Name("FileId"))) .Properties(p => p.Object <dynamic>(f => f.Name("Properties") .Properties(np => np.Object <dynamic>(t => t.Name("ChemicalProperties") .Properties(cp => cp.Text(tp => tp.Name("Value"))))))))); break; default: createIndexRequest = new CreateIndexDescriptor(indexName) .Mappings(s => s .Map(typeName, tm => tm .Properties(p => p .Keyword(k => k.Name("OwnedBy")) ))); break; } try { await elasticClient.CreateIndexAsync(createIndexRequest); Log.Information($"Created mapping for index: '{indexName}', type: '{typeName}'"); } catch (ElasticsearchClientException e) { Log.Error($"Creating mapping server error: {e.Response.ServerError}"); } } }
private static async Task <ICreateIndexResponse> CreateIndexAsync( IElasticClient client, IIndexSettings indexSettings, MappingsDescriptor mappings, string indexName) { indexSettings = indexSettings ?? new IndexSettings(); mappings = mappings ?? new MappingsDescriptor(); var response = await client.CreateIndexAsync( indexName, createDescriptor => createDescriptor .Settings(settingDescriptor => settingDescriptor .NumberOfShards(indexSettings.NumberOfShards) .FileSystemStorageImplementation( indexSettings.FileSystemStorageImplementation)) .Mappings(mappingsDescriptor => mappings)); return(response); }
private async Task CreateIndex(IElasticClient client) { var indexAsync = await client.CreateIndexAsync(_setup.IndexName, i => i .Mappings(m => m.Map <EssayDocument>(MapEssay)) .Settings(s => s .Analysis(a => a .Analyzers(aa => aa .Snowball(WithStopwordsAnalyzerIdentifier, sd => sd.Language(SnowballLanguage.Russian) .StopWords("как", "почему", "зачем", "очевидно") ) .Snowball(ForAllWordsAnalyzerIdentifier, sd => sd.Language(SnowballLanguage.Russian)) ) .CharFilters(cf => cf.HtmlStrip("html")) ))); if (!indexAsync.IsValid) { _logger.LogError("Index creation operation is reported as invalid."); } }
public async Task Create_Indices_when_index_is_incorrectly_named_same_as_index_alias() { // Arrange await _elasticClient.CreateIndexAsync(Constants.ElasticSearchIndices.ProjectsIndexName); // Act var indecisResult = await _elasticClient.CatIndicesAsync(); await _elasticSearchIndexService.CreateIndices(); var createdIndecisResult = await _elasticClient.CatIndicesAsync(); // Assert indecisResult.Records.Count.Should().Be(1); indecisResult.Records.Should().Contain((index) => index.Index == Constants.ElasticSearchIndices.ProjectsIndexName); createdIndecisResult.Records.Count.Should().BeGreaterThan(1); createdIndecisResult.Records.Count.Should().Be(5); createdIndecisResult.Records.Should().NotContain((index) => index.Index == Constants.ElasticSearchIndices.ProjectsIndexName); }
public async Task <bool> Initialize() { await _client.CreateIndexAsync(typeof(Payment.Payment.Models.PaymentIndex).FullName.ToLower(), i => i .Settings(s => s .NumberOfShards(3) .TotalShardsPerNode(3) .NumberOfReplicas(0) .Analysis(analysis => analysis .TokenFilters(f => f.NGram("ngram", d => d.MinGram(3).MaxGram(4))) .Analyzers(a => a .Custom("default", t => t.Tokenizer("keyword").Filters(new[] { "standard", "lowercase", "asciifolding", "kstem", "ngram" })) ) ) ) .Mappings(mappings => mappings.Map <Payment.Payment.Models.PaymentIndex>(map => map.Properties(props => props.Keyword(s => s.Name("Id").IgnoreAbove(256).Norms(false).IndexOptions(IndexOptions.Docs)) .Keyword(s => s.Name("UserName").IgnoreAbove(256).Norms(false).IndexOptions(IndexOptions.Docs)) .Keyword(s => s.Name("GivenName").IgnoreAbove(256).Norms(false).IndexOptions(IndexOptions.Docs)) .Keyword(s => s.Name("Status").IgnoreAbove(256).Norms(false).IndexOptions(IndexOptions.Docs)) .Keyword(s => s.Name("StatusDescription").IgnoreAbove(256).Norms(false).IndexOptions(IndexOptions.Docs)) .Keyword(s => s.Name("OrderId").IgnoreAbove(256).Norms(false).IndexOptions(IndexOptions.Docs)) .Number(s => s.Name("TotalPayment").Type(NumberType.Long)) .Keyword(s => s.Name("PaymentMethodCardholder").IgnoreAbove(256).Norms(false).IndexOptions(IndexOptions.Docs)) .Keyword(s => s.Name("PaymentMethodMethod").IgnoreAbove(256).Norms(false).IndexOptions(IndexOptions.Docs)) .Keyword(s => s.Name("Reference").IgnoreAbove(256).Norms(false).IndexOptions(IndexOptions.Docs)) .Number(s => s.Name("Created").Type(NumberType.Long)) .Number(s => s.Name("Updated").Type(NumberType.Long)) .Number(s => s.Name("Settled").Type(NumberType.Long)) )))).ConfigureAwait(false); this.Done = true; return(true); }
public async Task <bool> Initialize() { await _client.CreateIndexAsync(typeof(Role.Models.RoleIndex).FullName.ToLower(), i => i .Settings(s => s .NumberOfShards(3) .TotalShardsPerNode(3) .NumberOfReplicas(0) .Analysis(analysis => analysis .TokenFilters(f => f.NGram("ngram", d => d.MinGram(3).MaxGram(4))) .Analyzers(a => a .Custom("default", t => t.Tokenizer("keyword").Filters(new[] { "standard", "lowercase", "asciifolding", "kstem", "ngram" })) ) ) ) .Mappings(mappings => mappings.Map <Role.Models.RoleIndex>(map => map.Properties(props => props.Keyword(s => s.Name("Id").IgnoreAbove(256).Norms(false).IndexOptions(IndexOptions.Docs)) .Keyword(s => s.Name("Name").IgnoreAbove(256).Norms(false).IndexOptions(IndexOptions.Docs)) .Number(s => s.Name("Users").Type(NumberType.Long).IgnoreMalformed()) .Boolean(s => s.Name("Disabled")) )))).ConfigureAwait(false); await _client.CreateIndexAsync(typeof(User.Models.User).FullName.ToLower(), i => i .Settings(s => s .NumberOfShards(3) .TotalShardsPerNode(3) .NumberOfReplicas(0) .Analysis(analysis => analysis .TokenFilters(f => f.NGram("ngram", d => d.MinGram(3).MaxGram(4))) .Analyzers(a => a .Custom("default", t => t.Tokenizer("keyword").Filters(new[] { "standard", "lowercase", "asciifolding", "kstem", "ngram" })) ) ) ) .Mappings(mappings => mappings.Map <User.Models.User>(map => map.Properties(props => props.Keyword(s => s.Name("Id").IgnoreAbove(256).Norms(false).IndexOptions(IndexOptions.Docs)) .Keyword(s => s.Name("GivenName").IgnoreAbove(256).Norms(false).IndexOptions(IndexOptions.Docs)) .Boolean(s => s.Name("Disabled")) .Keyword(s => s.Name("Roles").IgnoreAbove(256).Norms(false).IndexOptions(IndexOptions.Docs)) .Number(s => s.Name("LastLogin").Type(NumberType.Long).IgnoreMalformed()) )))).ConfigureAwait(false); await _client.CreateIndexAsync(typeof(User.Services.UsersWithRoleHandler.UserRoles).FullName.ToLower(), i => i .Settings(s => s .NumberOfShards(3) .TotalShardsPerNode(3) .NumberOfReplicas(0) .Analysis(analysis => analysis .TokenFilters(f => f.NGram("ngram", d => d.MinGram(3).MaxGram(4))) .Analyzers(a => a .Custom("default", t => t.Tokenizer("keyword").Filters(new[] { "standard", "lowercase", "asciifolding", "kstem", "ngram" })) ) ) ) .Mappings(mappings => mappings.Map <User.Models.User>(map => map.Properties(props => props.Keyword(s => s.Name("RoleId").IgnoreAbove(256).Norms(false).IndexOptions(IndexOptions.Docs)) .Keyword(s => s.Name("Users").IgnoreAbove(256).Norms(false).IndexOptions(IndexOptions.Docs)) )))).ConfigureAwait(false); this.Done = true; return(true); }
public async Task <bool> Initialize() { await _client.CreateIndexAsync(typeof(Buyer.Models.OrderingBuyerIndex).FullName.ToLower(), i => i .Settings(s => s .NumberOfShards(3) .TotalShardsPerNode(3) .NumberOfReplicas(0) .Analysis(analysis => analysis.AutoCompleteAnalyzers()) ) .Mappings(mappings => mappings.Map <Buyer.Models.OrderingBuyerIndex>(map => map.Properties(props => props.Keyword(s => s.Name(x => x.Id).IgnoreAbove(256)) .Text(s => s.Name(x => x.GivenName).Fields(x => x.AutoCompleteFields())) .Boolean(s => s.Name(x => x.GoodStanding)) .Number(s => s.Name(x => x.TotalSpent).Type(NumberType.Long)) .Text(s => s.Name(x => x.PreferredCity).Fields(x => x.AutoCompleteFields())) .Text(s => s.Name(x => x.PreferredState).Fields(x => x.AutoCompleteFields())) .Text(s => s.Name(x => x.PreferredCountry).Fields(x => x.AutoCompleteFields())) .Text(s => s.Name(x => x.PreferredZipCode).Fields(x => x.AutoCompleteFields())) .Text(s => s.Name(x => x.PreferredPaymentCardholder).Fields(x => x.AutoCompleteFields())) .Text(s => s.Name(x => x.PreferredPaymentMethod).Fields(x => x.AutoCompleteFields())) .Text(s => s.Name(x => x.PreferredPaymentExpiration).Fields(x => x.AutoCompleteFields())) )))).ConfigureAwait(false); await _client.CreateIndexAsync(typeof(Buyer.Entities.Address.Models.Address).FullName.ToLower(), i => i .Settings(s => s .NumberOfShards(3) .TotalShardsPerNode(3) .NumberOfReplicas(0) .Analysis(analysis => analysis.AutoCompleteAnalyzers()) ) .Mappings(mappings => mappings.Map <Buyer.Entities.Address.Models.Address>(map => map.Properties(props => props.Keyword(s => s.Name(x => x.Id).IgnoreAbove(256)) .Keyword(s => s.Name(x => x.UserName).IgnoreAbove(256)) .Text(s => s.Name(x => x.Alias).Fields(x => x.AutoCompleteFields())) .Text(s => s.Name(x => x.Street).Fields(x => x.AutoCompleteFields())) .Text(s => s.Name(x => x.City).Fields(x => x.AutoCompleteFields())) .Text(s => s.Name(x => x.State).Fields(x => x.AutoCompleteFields())) .Text(s => s.Name(x => x.Country).Fields(x => x.AutoCompleteFields())) .Text(s => s.Name(x => x.ZipCode).Fields(x => x.AutoCompleteFields())) )))).ConfigureAwait(false); await _client.CreateIndexAsync(typeof(Buyer.Entities.PaymentMethod.Models.PaymentMethod).FullName.ToLower(), i => i .Settings(s => s .NumberOfShards(3) .TotalShardsPerNode(3) .NumberOfReplicas(0) .Analysis(analysis => analysis.AutoCompleteAnalyzers()) ) .Mappings(mappings => mappings.Map <Buyer.Entities.PaymentMethod.Models.PaymentMethod>(map => map.Properties(props => props.Keyword(s => s.Name(x => x.Id).IgnoreAbove(256)) .Keyword(s => s.Name(x => x.UserName).IgnoreAbove(256)) .Text(s => s.Name(x => x.Alias).Fields(x => x.AutoCompleteFields())) .Text(s => s.Name(x => x.CardNumber).Fields(x => x.AutoCompleteFields())) .Text(s => s.Name(x => x.SecurityNumber).Fields(x => x.AutoCompleteFields())) .Text(s => s.Name(x => x.CardholderName).Fields(x => x.AutoCompleteFields())) .Date(s => s.Name(x => x.Expiration)) .Text(s => s.Name(x => x.CardType).Fields(x => x.AutoCompleteFields())) )))).ConfigureAwait(false); await _client.CreateIndexAsync(typeof(Order.Models.OrderingOrder).FullName.ToLower(), i => i .Settings(s => s .NumberOfShards(3) .TotalShardsPerNode(3) .NumberOfReplicas(0) .Analysis(analysis => analysis.AutoCompleteAnalyzers()) ) .Mappings(mappings => mappings.Map <Order.Models.OrderingOrder>(map => map.Properties(props => props.Keyword(s => s.Name(x => x.Id).IgnoreAbove(256)) .Keyword(s => s.Name(x => x.UserName).IgnoreAbove(256)) .Text(s => s.Name(x => x.BuyerName).Fields(x => x.AutoCompleteFields())) .Keyword(s => s.Name(x => x.Status).IgnoreAbove(256)) .Keyword(s => s.Name(x => x.StatusDescription).IgnoreAbove(256)) .Keyword(s => s.Name(x => x.BillingAddressId).IgnoreAbove(256)) .Text(s => s.Name(x => x.BillingAddress).Fields(x => x.AutoCompleteFields())) .Text(s => s.Name(x => x.BillingCityState).Fields(x => x.AutoCompleteFields())) .Text(s => s.Name(x => x.BillingZipCode).Fields(x => x.AutoCompleteFields())) .Text(s => s.Name(x => x.BillingCountry).Fields(x => x.AutoCompleteFields())) .Keyword(s => s.Name(x => x.ShippingAddressId).IgnoreAbove(256)) .Text(s => s.Name(x => x.ShippingAddress).Fields(x => x.AutoCompleteFields())) .Text(s => s.Name(x => x.ShippingCityState).Fields(x => x.AutoCompleteFields())) .Text(s => s.Name(x => x.ShippingZipCode).Fields(x => x.AutoCompleteFields())) .Text(s => s.Name(x => x.ShippingCountry).Fields(x => x.AutoCompleteFields())) .Keyword(s => s.Name(x => x.PaymentMethodId).IgnoreAbove(256)) .Text(s => s.Name(x => x.PaymentMethod).Fields(x => x.AutoCompleteFields())) .Number(s => s.Name(x => x.TotalItems).Type(NumberType.Long)) .Number(s => s.Name(x => x.TotalQuantity).Type(NumberType.Long)) .Number(s => s.Name(x => x.SubTotal).Type(NumberType.Long)) .Number(s => s.Name(x => x.AdditionalFees).Type(NumberType.Long)) .Number(s => s.Name(x => x.AdditionalTaxes).Type(NumberType.Long)) .Number(s => s.Name(x => x.Total).Type(NumberType.Long)) .Date(s => s.Name(x => x.Created).Format("epoch_millis")) .Date(s => s.Name(x => x.Updated).Format("epoch_millis")) .Boolean(s => s.Name(x => x.Paid)) .Nested <Order.Entities.Item.Models.OrderingOrderItem>(s => s .Name(x => x.Items) .Properties(prop => prop .Keyword(t => t.Name(x => x.Id).IgnoreAbove(256)) .Keyword(t => t.Name(x => x.OrderId).IgnoreAbove(256)) .Keyword(t => t.Name(x => x.ProductId).IgnoreAbove(256)) .Binary(t => t.Name(x => x.ProductPictureContents)) .Keyword(t => t.Name(x => x.ProductPictureContentType).IgnoreAbove(256)) .Text(t => t.Name(x => x.ProductName).Fields(x => x.AutoCompleteFields())) .Text(t => t.Name(x => x.ProductDescription).Fields(x => x.AutoCompleteFields())) .Number(t => t.Name(x => x.ProductPrice).Type(NumberType.Long)) .Number(t => t.Name(x => x.Price).Type(NumberType.Long)) .Number(t => t.Name(x => x.Quantity).Type(NumberType.Long)) .Number(t => t.Name(x => x.SubTotal).Type(NumberType.Long)) .Number(t => t.Name(x => x.AdditionalFees).Type(NumberType.Long)) .Number(t => t.Name(x => x.AdditionalTaxes).Type(NumberType.Long)) .Number(t => t.Name(x => x.Total).Type(NumberType.Long)) )) )))).ConfigureAwait(false); await _client.CreateIndexAsync(typeof(Order.Models.OrderingOrderIndex).FullName.ToLower(), i => i .Settings(s => s .NumberOfShards(3) .TotalShardsPerNode(3) .NumberOfReplicas(0) .Analysis(analysis => analysis.AutoCompleteAnalyzers()) ) .Mappings(mappings => mappings.Map <Order.Models.OrderingOrderIndex>(map => map.Properties(props => props.Keyword(s => s.Name(x => x.Id).IgnoreAbove(256)) .Keyword(s => s.Name(x => x.UserName).IgnoreAbove(256)) .Text(s => s.Name(x => x.BuyerName).Fields(x => x.AutoCompleteFields())) .Keyword(s => s.Name(x => x.Status).IgnoreAbove(256)) .Keyword(s => s.Name(x => x.StatusDescription).IgnoreAbove(256)) .Keyword(s => s.Name(x => x.BillingAddressId).IgnoreAbove(256)) .Text(s => s.Name(x => x.BillingAddress).Fields(x => x.AutoCompleteFields())) .Text(s => s.Name(x => x.BillingCity).Fields(x => x.AutoCompleteFields())) .Text(s => s.Name(x => x.BillingState).Fields(x => x.AutoCompleteFields())) .Text(s => s.Name(x => x.BillingZipCode).Fields(x => x.AutoCompleteFields())) .Text(s => s.Name(x => x.BillingCountry).Fields(x => x.AutoCompleteFields())) .Keyword(s => s.Name(x => x.ShippingAddressId).IgnoreAbove(256)) .Text(s => s.Name(x => x.ShippingAddress).Fields(x => x.AutoCompleteFields())) .Text(s => s.Name(x => x.ShippingCity).Fields(x => x.AutoCompleteFields())) .Text(s => s.Name(x => x.ShippingState).Fields(x => x.AutoCompleteFields())) .Text(s => s.Name(x => x.ShippingZipCode).Fields(x => x.AutoCompleteFields())) .Text(s => s.Name(x => x.ShippingCountry).Fields(x => x.AutoCompleteFields())) .Keyword(s => s.Name(x => x.PaymentMethodId).IgnoreAbove(256)) .Text(s => s.Name(x => x.PaymentMethod).Fields(x => x.AutoCompleteFields())) .Number(s => s.Name(x => x.TotalItems).Type(NumberType.Long)) .Number(s => s.Name(x => x.TotalQuantity).Type(NumberType.Long)) .Number(s => s.Name(x => x.SubTotal).Type(NumberType.Long)) .Number(s => s.Name(x => x.Additional).Type(NumberType.Long)) .Number(s => s.Name(x => x.Total).Type(NumberType.Long)) .Date(s => s.Name(x => x.Created).Format("epoch_millis")) .Date(s => s.Name(x => x.Updated).Format("epoch_millis")) .Boolean(s => s.Name(x => x.Paid)) )))).ConfigureAwait(false); await _client.CreateIndexAsync(typeof(Order.Entities.Item.Models.OrderingOrderItem).FullName.ToLower(), i => i .Settings(s => s .NumberOfShards(3) .TotalShardsPerNode(3) .NumberOfReplicas(0) .Analysis(analysis => analysis.AutoCompleteAnalyzers()) ) .Mappings(mappings => mappings.Map <Order.Entities.Item.Models.OrderingOrderItem>(map => map.Properties(props => props.Keyword(s => s.Name(x => x.Id).IgnoreAbove(256)) .Keyword(s => s.Name(x => x.OrderId).IgnoreAbove(256)) .Keyword(s => s.Name(x => x.ProductId).IgnoreAbove(256)) .Binary(s => s.Name(x => x.ProductPictureContents)) .Keyword(s => s.Name(x => x.ProductPictureContentType).IgnoreAbove(256)) .Text(s => s.Name(x => x.ProductName).Fields(x => x.AutoCompleteFields())) .Text(s => s.Name(x => x.ProductDescription).Fields(x => x.AutoCompleteFields())) .Number(s => s.Name(x => x.ProductPrice).Type(NumberType.Long)) .Number(s => s.Name(x => x.Price).Type(NumberType.Long)) .Number(s => s.Name(x => x.Quantity).Type(NumberType.Long)) .Number(s => s.Name(x => x.SubTotal).Type(NumberType.Long)) .Number(s => s.Name(x => x.AdditionalFees).Type(NumberType.Long)) .Number(s => s.Name(x => x.AdditionalTaxes).Type(NumberType.Long)) .Number(s => s.Name(x => x.Total).Type(NumberType.Long)) )))).ConfigureAwait(false); await _client.CreateIndexAsync(typeof(Order.Models.SalesByState).FullName.ToLower(), i => i .Settings(s => s .NumberOfShards(3) .TotalShardsPerNode(3) .NumberOfReplicas(0) .Analysis(analysis => analysis.AutoCompleteAnalyzers()) ) .Mappings(mappings => mappings.Map <Order.Models.SalesByState>(map => map.Properties(props => props.Keyword(s => s.Name(x => x.Id).IgnoreAbove(256)) .Keyword(s => s.Name(x => x.State).IgnoreAbove(256)) .Number(s => s.Name(x => x.Relevancy).Type(NumberType.Long)) .Number(s => s.Name(x => x.Value).Type(NumberType.Long)) )))).ConfigureAwait(false); await _client.CreateIndexAsync(typeof(Order.Models.SalesChart).FullName.ToLower(), i => i .Settings(s => s .NumberOfShards(3) .TotalShardsPerNode(3) .NumberOfReplicas(0) .Analysis(analysis => analysis.AutoCompleteAnalyzers()) ) .Mappings(mappings => mappings.Map <Order.Models.SalesChart>(map => map.Properties(props => props.Keyword(s => s.Name(x => x.Id).IgnoreAbove(256)) .Keyword(s => s.Name(x => x.Label).IgnoreAbove(256)) .Number(s => s.Name(x => x.Relevancy).Type(NumberType.Long)) .Number(s => s.Name(x => x.Value).Type(NumberType.Long)) )))).ConfigureAwait(false); await _client.CreateIndexAsync(typeof(Order.Models.SalesWeekOverWeek).FullName.ToLower(), i => i .Settings(s => s .NumberOfShards(3) .TotalShardsPerNode(3) .NumberOfReplicas(0) .Analysis(analysis => analysis.AutoCompleteAnalyzers()) ) .Mappings(mappings => mappings.Map <Order.Models.SalesWeekOverWeek>(map => map.Properties(props => props.Keyword(s => s.Name(x => x.Id).IgnoreAbove(256)) .Keyword(s => s.Name(x => x.DayOfWeek).IgnoreAbove(256)) .Number(s => s.Name(x => x.Relevancy).Type(NumberType.Long)) .Number(s => s.Name(x => x.Value).Type(NumberType.Long)) )))).ConfigureAwait(false); this.Done = true; return(true); }