Search code examples
c#elasticsearchnest

Invalid NEST response built from a unsuccessful low level call on POST


I want to configurate NEST from c# code When I use Kibana command GET /_cat/indices?v

I get this result:

enter image description here

My test index is "customer"

I'm using Elasticsearch.Net and NEST: the .NET clients [6.x] Elastic "6.5.4", Now this is how I configurate on C#:

  var settings = new ConnectionSettings(new Uri("http://localhost:9200"))
.DefaultIndex("customer");

        var client = new ElasticClient(settings);



        var newCustomer = new Customer
        {
            name = "test_name",
            OS = "test_os",
            script = "test_script"
        };


        var indexResponse = client.IndexDocument(newCustomer);

and I get an error:

Invalid NEST response built from a unsuccessful low level call on POST: /customer/customer

why does it build request to /customer/customer ??? What am I configurating wrong?

Error message:

Invalid NEST response built from a unsuccessful low level call on POST: /customer/customer Audit trail of this API call: - BadResponse: Node: http://localhost:9200/ Took: 00:00:00.2817669 OriginalException: Elasticsearch.Net.ElasticsearchClientException: Удаленный сервер возвратил ошибку: (400) Недопустимый запрос.. Call: Status code 400 from: POST /customer/customer. ServerError: Type: illegal_argument_exception Reason: "Rejecting mapping update to [customer] as the final mapping would have more than 1 type: [_doc, customer]" ---> System.Net.WebException: Удаленный сервер возвратил ошибку: (400) Недопустимый запрос.


Solution

  • You have already a mapping in ES and the document you want to index doesnot match with it.