Elastic search model (rails), adds a new field to the display

Below is the API for updating Elastic search display

PUT twitter/_mapping/tweet 
{
 "properties": {
   "user_name": {
    "type": "string"
   }
  }
 }

This will add a new field named user_name to the tweet display type. How to achieve this using the pearl of an elastic search model https://github.com/elastic/elasticsearch-rails/tree/master/elasticsearch-model

+4
source share
1 answer

You can use put_mapping API for this purpose.

In 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 
})
+10
source

Source: https://habr.com/ru/post/1624902/


All Articles