Create document which nested fields does not work correctly in elasticsearch.js

elasticsearch.js. Version: 12.1.3

If I try to create a document which contains nested fields then only the fields of the enclosing document are saved but the nested document not. Here is an example code:

const elasticsearch = require('elasticsearch');
client =  new elasticsearch.Client();
   index: 'myindex',
   body: {
      mappings: {
         book: {
            properties: {
               title: {
                  type: 'text'
               authors: {
                  'type': 'nested',
                  'properties': {
                     'name': {
                        'type': 'test'
.then(function() {
   elasticsearchClient.create( {
      index: 'myindex',
      type: 'book',
      id: 1,
      body: {id:1, title: 'my first book', authors: [{name: 'author1'}, {name: 'author2'}]}

The result in elasticsearch is a book document which contains only the title but not the authors.

Can anybody help me?

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