public void CreateIndexSettingsAndMappingsForDocument(string index, IndexSettings indexSettings, IndexAliases indexAliases, IndexWarmers indexWarmers, EntityContextInfo entityInfo, MappingDefinition mappingDefinition) { if (_processedItems.Contains("_index" + index)) { return; } _processedItems.Add("_index" + index); var elasticCrudJsonWriter = new ElasticJsonWriter(); elasticCrudJsonWriter.JsonWriter.WriteStartObject(); CreateIndexSettings(elasticCrudJsonWriter, indexSettings); indexAliases.WriteJson(elasticCrudJsonWriter); indexWarmers.WriteJson(elasticCrudJsonWriter); IndexSettingsCreatePropertyMappingForTopDocument(entityInfo, mappingDefinition, elasticCrudJsonWriter); elasticCrudJsonWriter.JsonWriter.WriteEndObject(); CreateIndexCommand(elasticCrudJsonWriter.GetJsonString(), index); }
public async Task <ResultDetails <string> > CreateIndexAsync(string index, IndexSettings indexSettings, IndexAliases indexAliases, IndexWarmers indexWarmers) { if (string.IsNullOrEmpty(index)) { throw new ElasticException("CreateIndexAsync: index is required"); } if (indexSettings == null) { indexSettings = new IndexSettings { NumberOfShards = 5, NumberOfReplicas = 1 } } ; if (indexAliases == null) { indexAliases = new IndexAliases(); } if (indexWarmers == null) { indexWarmers = new IndexWarmers(); } _traceProvider.Trace(TraceEventType.Verbose, "{0}: CreateIndexAsync Elastic started", "ElasticContextIndexMapping"); var resultDetails = new ResultDetails <string> { Status = HttpStatusCode.InternalServerError }; try { MappingUtils.GuardAgainstBadIndexName(index); var indexMappings = new IndexMappings(_traceProvider, _elasticSerializerConfiguration); indexMappings.CreateIndexSettingsForDocument(index, indexSettings, indexAliases, indexWarmers); await indexMappings.Execute(_client, _connectionString, _traceProvider, _cancellationTokenSource); return(resultDetails); } catch (OperationCanceledException oex) { _traceProvider.Trace(TraceEventType.Warning, oex, "{1}: CreateIndexAsync Request OperationCanceledException: {0}", oex.Message, "ElasticContextIndexMapping"); resultDetails.Description = "OperationCanceledException"; return(resultDetails); } }
public void CreateIndexSettingsForDocument(string index, IndexSettings indexSettings, IndexAliases indexAliases, IndexWarmers indexWarmers) { if (_processedItems.Contains("_index" + index)) { return; } _processedItems.Add("_index" + index); var elasticsearchCrudJsonWriter = new ElasticsearchCrudJsonWriter(); elasticsearchCrudJsonWriter.JsonWriter.WriteStartObject(); CreateIndexSettings(elasticsearchCrudJsonWriter, indexSettings); indexAliases.WriteJson(elasticsearchCrudJsonWriter); indexWarmers.WriteJson(elasticsearchCrudJsonWriter); elasticsearchCrudJsonWriter.JsonWriter.WriteEndObject(); CreateIndexCommand(elasticsearchCrudJsonWriter.GetJsonString(), index); }
public ResultDetails <string> CreateIndex(string index, IndexSettings indexSettings, IndexAliases indexAliases, IndexWarmers indexWarmers) { var syncExecutor = new SyncExecute(_traceProvider); return(syncExecutor.ExecuteResultDetails(() => CreateIndexAsync(index, indexSettings, indexAliases, indexWarmers))); }