I am using the elasticsearch 5.2 node.js module.
I know that elasticsearch.index() creates the index if it's not already created. The problem, though, is that I am using a special mapping on one of the fields.
For example if I'd recreate an index & type, I'd use something like this:
client.indices.putMapping({
index: INDEX,
type: TYPE,
body: {
properties: {
field1: {
type: 'string',
analyzer: 'keyword'
}
}
}
}
before I do all the indexes, so that the mapping is persistent in that INDEX & TYPE.
What I want is, when I have a new TYPE, to use elasticsearch.index() but don't want to have to use elasticsearch.indices.putMapping() each time in order to guarantee that the desired mapping is consistent across all types inside that index.
The question is:
Is it necessary to use elasticsearch.indices.putMapping() each time there's a new TYPE? And if so, what's the easiest way of propagating a certain same mapping inside an index each time a new TYPE is used?
Thanks a lot in advance!