13

In Elasticsearch.NET 6.x, it is possible create an index using IElasticClient method:

var response = elasticClient.Create(
                    "my-index-name",
                    index =>  index .Mappings(
                        ms => ms.Map<MyDocumentType>(
                            x => x.AutoMap()
                        )
                    )
                );

Method is removed in Elasticsearch.NET version 7.

Nenad
  • 24,809
  • 11
  • 75
  • 93

1 Answers1

24

In Elasticsearch.NET version 7 methods related to indices operations are moved into IndicesNamespace, so IndexExists method has been moved to:

var response = elasticClient.Indices.Create(IndexName,
                    index => index.Map<ElasticsearchDocument>(
                        x => x.AutoMap()
                    ));

Also note, that Map(...) method is no longer nested inside of Mappings(...) method. Reason is that Elasticsearch server version 7 supports does not support multiple types per index (see Removal of mapping types), so one Map method per index is sufficient.

Similarly, different methods have been moved to their own namespaces:

  • Cat
  • Cluster
  • Graph
  • Sql
  • Nodes
  • etc...
Nenad
  • 24,809
  • 11
  • 75
  • 93
  • 1
    To help with upgrading, there is a NEST7x.UpgradeAssistant Nuget package. See "Namespaced API methods and Upgrade Assistant" under release notes: https://github.com/elastic/elasticsearch-net/releases/tag/7.0.0 – Russ Cam Jul 01 '19 at 21:36