Home > Enterprise >  Upgrading elasticsearch: what is the state of "types" in version 7?
Upgrading elasticsearch: what is the state of "types" in version 7?

Time:07-21

I am in the process of upgrading Elasticsearch. I upgraded elasticsearch from 6.8 to 7.17 and I upgraded the javascript client to @elastic/elasticsearch 7.17.0. I then deleted my old indices, put the mappings in place and tried to reindex the data coming from another database.

Now I am struggling with the current state of types in elasticsearch 7.17. I know that an index can only have one type of document and it looks like the type parameter of the javascript client is deprecated, but it still seems to be required. When I make a call to client.index() it complains about a missing type parameter:

ConfigurationError: Missing required parameter: type

And the error stack points to this block of code:

    await client.index({
      index: indexName,
      id: obj.id,
      body: obj.body,
    });

My mappings look like this:

{
  "author_index" : {
    "mappings" : {
      "dynamic" : "false",
      "properties" : {
        "articleCount" : {
          "type" : "integer"
        }
        // ,,,
      }
    }
  }
}

Should I still be specifying the type? Why does the client require it when its deprecated? What am I missing?

CodePudding user response:

Replace your type with _doc and it should work as type is deprecated but you still need to give the _doc placeholder in the API calls.

  • Related