NEST Bulk API Validation Error: type is missing

Hi,

I'm experiencing
"Invalid NEST response built from a unsuccessful (400) low level call on POST: /indexname/_bulk"
Bad Request with '{Type: action_request_validation_exception Reason: "Validation Failed: 1: type is missing;2: type is missing;"}'

When I'm attempting to make bulk api calls into our elasticsearch cluster.

NEST Client: 7.8.2
Elasticsearch Version: 6.5 (AWS hosted Elasticsearch Service)

Setup of the Client:

            var httpConnection = new AwsHttpConnection(awsRegion);

            var pool = new SingleNodeConnectionPool(new Uri(elasticSearchEndpoint));
            var config = new ConnectionSettings(pool, httpConnection);
            var esclient = new ElasticClient(config);

This is just an example, but I've tried multiple different variations of the bulk or index many call all with the same results:

            var doc= new ProductModel
            {
                Id = 1,
                Quantity = "5",
                Price = "25"
            };

            var docs = new List<DocumentModel>() { doc};

            BulkDescriptor bulkDescriptor = new BulkDescriptor(indexName.ToLowerInvariant()){};
            BulkResponse response = ElasticClient.Bulk(bulkDescriptor.IndexMany(docs));

Couple of side notes,

  1. We have a working index call below:
    IndexResponse response = ElasticClient.Index(new IndexRequest(doc, indexName));
    I noticed that the IndexRequest object uses the path of " /{index}/_doc/{id}"

  2. We have used postman to make calls into our elasticsearch hitting the bulk endpoint
    POST https:/ClusterUrl/indexname/_doc/_bulk

I have a feeling the bulk call is failing because mapping types aren't supported in 7 and I can't supply the 'type' field to any of the bulk/indexmany calls.

Any help appreciated.

Hi @lmattingly,

You must use NEST 6.x with Elasticsearch 6.x. A major version of the client is compatible with the same major version of Elasticsearch, so you can use the latest 6.x NEST version with Elasticsearch 6.5. Check out the compatibility docs for more details.

Hi @forloop,

Thanks. I'll definitely work towards upgrading our Elasticsearch version. Is there an ideal place to look for upgrade process/changes that could affect us when upgrading versions?

I had issues with other ES calls when I downgraded our library. I was able to find a work around though, even though this might not be best practice.

I added a type query string to include the _doc which allowed the bulk call to be successful.

                BulkResponse response = ElasticClient.Bulk(bulkDescriptor.IndexMany(docs).TypeQueryString("_doc"));

I would still recommend using NEST 6.x and fix the issues you came across as you may run across other incompatibilities between Elasticsearch 6.x and NEST 7.x which can't be easily worked around.

It's a good idea to look at both the Elasticsearch changes and client changes when looking at an upgrade:

The client changes will include changes that originate from changes in Elasticsearch, in addition to client specific changes.

1 Like

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.