The state of 'types' in elasticsearch 7

I am using Elasticsearch 7.17 and the corresponding javacript client @elastic/elasticsearch@7.17. My understanding is that only one type of document can be stored in an index and as such specifying explicit types is deprecated when indexing documents.

However when indexing a document using the javascript client I get this error:

ConfigurationError: Missing required parameter: type

The stack trace of the error points to this block of code:

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

It turns out that if I add type: '_doc', it works:

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

Which is strange because the client docs say the type field is deprecated and they don't include the type in their examples either.

Is this a mistake in the javascript client or am I overlooking something?

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