Change Mapping of Existing Data


(krishna singh) #1

I want to change my mapping.What should I do to apply new mapping for existing data?please help me out.

POST /thegame/weapons/1
{
"_id": 1,
"name": "Longsword",
"category": "Sharp"
}

GET /thegame/weapons/_mapping

POST /thegame/_close

PUT /thegame/weapons/_mapping?ignore_conflicts=true
{
"weapons": {
"properties": {
"name": {
"type": "long",
},
"category": {
"type": "string"
}
}
}
}

POST /thegame/_open
GET /thegame/_mappings

Firstly,i put a docs it create default mapping (name:{type:string}),I want to change my default mapping (name:{type:long}).It showing me Error.
Please help me out.
If I reindex my data through Snapshot then also i am not able to change my mapping.


(Magnus Bäck) #2

You have you reindex the data into a new index that has the correct mapping.


(krishna singh) #3

HOw to reindex data..please give me some solution??


(Magnus Bäck) #4

You can e.g. use Logstash, es-reindex, or write a custom script in e.g. Python. This has been discussed in these forums several times before so please consult the archives and come back with more specific questions.


(system) #6