Mapping in ELK 6.1 with the Ruby Rest Client

Hi,
With the latest changes from the ELK 6.1.1 on the Removal of Mapping types, my ruby code doesn't work to create the mapping. Could you please let me know if I am doing anything wrong the mapping created in json file.
Below is the code snippet:

require 'rest_client'
require 'json'

def create_mapping
file = File.read('test.json')
RestClient.put 'http://localhost:9200/testing', file
end

test.json consists as below:

{
"mappings": {
"features": {
"properties": {
"@timestamp": {
"type": "date",
"format": "dateOptionalTime"
},
"build_number": {
"type": "integer",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"job_name": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
}
}
}
}
}

The same mapping works fine on the Kibana dev tools with the PUT method, but doesn't work with the Ruby client.

The error message returned from ruby rest client is "406 Not Acceptable (RestClient::NotAcceptable)"

Could you please let me know how do I fix this issue. Thanks !

Please format your code using </> icon as explained in this guide. It will make your post more readable.

Or use markdown style like:

```
CODE
```

Do you set in your client somewhere the Content-Type?

1 Like

Thanks for your reply @dadoonet, after adding the content type, it works. :slight_smile:

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.