Skip to content

Instantly share code, notes, and snippets.

@ThomasArdal
Created June 16, 2014 06:20
Show Gist options
  • Save ThomasArdal/ce32939ef1a5a079fed5 to your computer and use it in GitHub Desktop.
Save ThomasArdal/ce32939ef1a5a079fed5 to your computer and use it in GitHub Desktop.
Create a new versioned Elasticsearch index
var connectionSettings = new ConnectionSettings(new Uri("http://localhost:9200/"));
connectionSettings.SetDefaultIndex("customers");
var elasticClient = new ElasticClient(connectionSettings);
elasticClient.CreateIndex("customers-v1");
elasticClient.Alias(x => x.Add(a => a.Alias("customers").Index("customers-v1")));
elasticClient.Map<Customer>(d =>
d.Properties(p => p.Number(n => n.Name(name => name.Zipcode).Index(NonStringIndexOption.not_analyzed))));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment