I have tested ElasticSearch in my localhost, it is working fine. But when I deployed to hosting server, it is not working. I use asphostportal.com. This is my code:
{public static class ElasticsearchExtensions
{
public static void AddElasticsearch(
this IServiceCollection services, IConfiguration configuration)
{
var defaultIndex ="hedonasp";
var settings = new ConnectionSettings(new Uri("https://711e0c87a+++++++=========dc2528152891.us-east-1.aws.found.io:7895"))
.DefaultIndex(defaultIndex)
.BasicAuthentication("elastic", "q1vqu++++++++yfV7RFS5WR6");
// AddDefaultMappings(settings);
var client = new ElasticClient(settings);
services.AddSingleton<IElasticClient>(client);
CreateIndex(client, defaultIndex);
}
private static void AddDefaultMappings(ConnectionSettings settings)
{
settings
.DefaultMappingFor<ElasticSearchModel>(m => m);
}
private static void CreateIndex(IElasticClient client, string indexName)
{
var createIndexResponse = client.CreateIndex("hedonasp", c => c
.Mappings(m => m.Map<ElasticSearchModel>(mm => mm
.AutoMap()
))
.RequestConfiguration(r => r
.DisableDirectStreaming()
)
);
Console.WriteLine("Writeline is :" + createIndexResponse);
}
}
}