How to create a new index in Elasticsearch 5 from .Net or NEST

I am trying to create a new Elastic 5 index from .net and the data from the SQL database into it using the massive API.

I created POCO to map:

using Nest;

namespace NEST5
{
  [ElasticsearchType(IdProperty = "data_id")]
  public class Test_Data
  {    
     public int data_id { get; set; }
     public string address { get; set; }
     public string location { get; set; }
  }
}

And I get the data from SQL into a list of type Test_Data p>

Then I try to connect to my Elasticsearch server and create an index:

var connectionPool = new SingleNodeConnectionPool(new Uri("http://<ip here>:9200/"));
var settings = new ConnectionSettings(connectionPool, new InMemoryConnection())
 .DefaultIndex("test_data")
 .BasicAuthentication("username", "password");

var client = new ElasticLowLevelClient(settings);

var descriptor = new CreateIndexDescriptor("test_data")
 .Mappings(ms => ms
 .Map<Test_Data>(m => m.AutoMap())
 );

client.IndicesCreate<Test_Data>("test_data", descriptor, null);

However, this does not show an error, but also does not create a new index.

Thanks in advance for any help.

+4
source share
1 answer

You are using the "new InMemoryConnection ()" in your ConnectionSettings, try deleting this.

0
source

Source: https://habr.com/ru/post/1662974/


All Articles