I\'m trying to create an elasticsearch index with mappings using the official javascript client.
My code is as follows:
Note: this uses client.indices.create() and not client.indices.putMapping()
I recently succeeded in creating an index with a custom mapping like this:
client.indices.create({
index: 'yourIndex',
body: {
yourIndex: {
mappings: {
yourType: {
properties: {
yourText: {
type: 'string',
}
}
}
}
}
}
});
It seems you have to start defining the body with your index, followed by the mappings keyword, followed by your type and so forth. I used the elasticsearch package version 15.4.1 with elastic version 6.5.4