-
-
Save DavyLin/04e5a5bc593a79ec51c9 to your computer and use it in GitHub Desktop.
Revisions
-
nicolashery revised this gist
Aug 29, 2013 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -49,7 +49,7 @@ $ curl -X POST 'http://localhost:9200/thegame/_open' To **update the mappings** of this existing index, you need to do it for each type (here we only have the `weapons` type): ```bash $ curl -X PUT 'http://localhost:9200/thegame/weapons/_mapping?ignore_conflicts=true' -d \ '{ "weapons": { "properties": { -
nicolashery revised this gist
Aug 29, 2013 . 1 changed file with 2 additions and 5 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -49,8 +49,7 @@ $ curl -X POST 'http://localhost:9200/thegame/_open' To **update the mappings** of this existing index, you need to do it for each type (here we only have the `weapons` type): ```bash $ curl -X PUT 'http://localhost:9200/thegame/weapons/_mapping' -d \ '{ "weapons": { "properties": { @@ -69,9 +68,7 @@ $ curl -X POST 'http://localhost:9200/thegame/weapons/_mapping' -d \ }' ``` You can do all of this at once if you delete then re-create your index, but you will **loose all stored documents**, so you will have to reload them. But sometimes for big changes to mapping/settings, this makes more sense: ```bash $ curl -X DELETE 'http://localhost:9200/thegame' -
nicolashery created this gist
Aug 23, 2013 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,112 @@ # Elasticsearch: updating the mappings and settings of an existing index *Note: This was written using elasticsearch 0.9.* [Elasticsearch](http://www.elasticsearch.org/) will automatically create an index (with basic settings and mappings) for you if you post a first document: ```bash $ curl -X POST 'http://localhost:9200/thegame/weapons/1' -d \ '{ "_id": 1, "name": "Longsword", "description": "The Longsword can be wielded in one or two hands and is also known as a Bastard Sword. It combines power, speed and reach to become one of the most well rounded weapons.", "category": "Sharp" }' ``` You can see the settings (for the index) and mapping (for the `weapons` type) with: ```bash $ curl -X GET 'http://localhost:9200/thegame/_settings' $ curl -X GET 'http://localhost:9200/thegame/weapons/_mapping' ``` To **update the settings**, if you're defining new analyzers or filters, you first need to `_close` the index, then `_open` it when done updating: ```bash $ curl -X POST 'http://localhost:9200/thegame/_close' $ curl -X PUT 'http://localhost:9200/thegame/_settings' -d \ '{ "analysis": { "analyzer": { "full_name": { "filter": [ "standard", "lowercase", "asciifolding" ], "type": "custom", "tokenizer": "standard" } } } }' $ curl -X POST 'http://localhost:9200/thegame/_open' ``` To **update the mappings** of this existing index, you need to do it for each type (here we only have the `weapons` type): ```bash $ curl -X DELETE 'http://localhost:9200/thegame/weapons/_mapping' $ curl -X POST 'http://localhost:9200/thegame/weapons/_mapping' -d \ '{ "weapons": { "properties": { "name": { "type": "string", "analyzer": "full_name" }, "description": { "type": "string" }, "category": { "type": "string" } } } }' ``` **Note**: Instead of using `PUT`, I like to use `DELETE` and `POST` to avoid any "merge conflict" errors. You can do all of this at once if you delete then re-create your index, but you will **loose all stored documents**: ```bash $ curl -X DELETE 'http://localhost:9200/thegame' $ curl -X POST 'http://localhost:9200/thegame' -d \ '{ "mappings": { "weapons": { "properties": { "name": { "type": "string", "analyzer": "full_name" }, "description": { "type": "string" }, "category": { "type": "string" } } } }, "settings": { "analysis": { "analyzer": { "full_name": { "filter": [ "standard", "lowercase", "asciifolding" ], "type": "custom", "tokenizer": "standard" } } } } }' ```