I\'m trying to create an elasticsearch index with mappings using the official javascript client.
My code is as follows:
None of these examples worked for me on ElasticSearch 5.3 API.
Here is an example that works for 5.3.
elasticClient.indices.putMapping({
index: indexName,
type: "document",
body: {
properties: {
title: { type: "string" },
content: { type: "string" },
suggest: {
type: "completion",
analyzer: "simple",
search_analyzer: "simple",
payloads: true
}
}
}
})
Note that the type has been pulled out of the body, and only the sub-params that were under the type are now in the body.
Source: https://blog.raananweber.com/2015/11/24/simple-autocomplete-with-elasticsearch-and-node-js/