Reputation:
Following is the API to update mapping of Elastic search
PUT twitter/_mapping/tweet
{
"properties": {
"user_name": {
"type": "string"
}
}
}
This add a new field called user_name to the tweet mapping type. How to achieve this using elastic search model gem https://github.com/elastic/elasticsearch-rails/tree/master/elasticsearch-model
Upvotes: 7
Views: 2198
Reputation: 166
You can use the put_mapping API for this purpose.
For your case, the following should work.
client = Elasticsearch::Model.client
data = { "tweet" => { "properties" => { "user_name" => { "type" => "string" } } } }
client.indices.put_mapping(
{
index: 'twitter',
type: 'tweet',
body: data
})
Upvotes: 11