I really don't understand the docs. Even after reading a few SO questions and answers (ex: this one). I have this code
let indexMapping = {
'foo': {
name: { type: 'string', index: 'analyzed' },
value: { index: 'no' },
dynamic_templates: [ {
customRule: {
path_match: 'bar.*',
mapping: { type: '{dynamic_type}', index: 'no' }
}
} ]
}
};
let indexName = 'foos';
let typeName = 'foo';
client.indices.putMapping({
index: indexName,
type: typeName,
[typeName]: {
properties: indexMapping[typeName]
}
}).catch(function (err) {
console.error(err.stack || err);
});
And I always get
Error: [action_request_validation_exception] Validation Failed: 1: mapping source is empty;
What am I doing wrong?
More info
My index is newly created, and there are no documents added or any types currently defined. This is a new, blank, index that I want to set mappings to before adding and indexing documents.