Reputation: 2158
I installed Elasticsearch 1.5.2 on CentOS as a service. I tried to add mappings using PUT:
curl -XPUT $ES_HOST/my_index -d'
{
"mappings": {
"my_type": {
"properties": {
"field": {
"type": "nested"
}
}
}
}
}'
That request works fine and creates new index with correct mappings.
Instead of putting mappings manually I want to store mappings on server in config files. For that I created file /etc/elasticsearch/mappings/my_index/all_mappings.json
with the same content as previous request body. After that I'm trying to create index curl -XPUT $ES_HOST/my_index
but the error occurs
{
"error": "MapperParsingException[mapping [all_mappings]]; nested:
MapperParsingException[Root type mapping not empty after parsing!
Remaining fields: [mappings : {my_type={properties={field={type=nested}}}}]]; ",
"status": 400
}
I tried to remove mappings
field in config json but nothing changed.
Upvotes: 0
Views: 155
Reputation: 52368
The name of the file is the mapping name. So, for /mappings/my_index/all_mappings.json
you should have the index my_index
and the type
called all_mappings
.
Also, the content of the file should be:
{
"properties": {
"field": {
"type": "nested"
}
}
}
These being said, do the following:
my_type.json
file under /etc/elasticsearch/mappings/my_index
folder {
"properties": {
"field": {
"type": "nested"
}
}
}
PUT /test_my_index
GET /test_my_index/_mapping
Upvotes: 1