User Tools
development:elasticsearch:elasticsearch
Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| development:elasticsearch:elasticsearch [2021/12/13 19:49] – slawrence | development:elasticsearch:elasticsearch [2021/12/16 07:15] (current) – slawrence | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| __**Re-Index ElasticSearch**__ | __**Re-Index ElasticSearch**__ | ||
| + | |||
| + | REF: https:// | ||
| There are potentially several situations where you may need to recreate the current Elastic Search index. | There are potentially several situations where you may need to recreate the current Elastic Search index. | ||
| Line 7: | Line 9: | ||
| If such an affecting data-type change is released after the first of the month, this can lead to errors in the MDC Tracker log file (~/ | If such an affecting data-type change is released after the first of the month, this can lead to errors in the MDC Tracker log file (~/ | ||
| + | <WRAP center round box 90%> | ||
| **// | **// | ||
| + | </ | ||
| This error implies that the existing data mapping for the current ElasticSearch index was expecting data of type ' | This error implies that the existing data mapping for the current ElasticSearch index was expecting data of type ' | ||
| Line 13: | Line 17: | ||
| To resolve this situation, the basic process is to look up existing indices, create a new schema with some manually specified data-type mapping, copy the existing index data to the new index, and then delete the old index. | To resolve this situation, the basic process is to look up existing indices, create a new schema with some manually specified data-type mapping, copy the existing index data to the new index, and then delete the old index. | ||
| - | To begin, log into the server running elasticsearch via SSH in a termanal window (i.e. newtowerqaesk1.err or the like). | + | **To begin, log into the server running elasticsearch via SSH in a termanal window (i.e. newtowerqaesk1.err or the like). |
| + | ** | ||
| + | **1. Retrieve existing indices: | ||
| + | ** | ||
| + | **RUN: | ||
| + | ** | ||
| + | <WRAP center round box 80%> | ||
| + | curl -X GET ' | ||
| + | </ | ||
| - | 1. Retrieve existing indices: | ||
| - | |||
| - | RUN: | ||
| - | |||
| - | curl -X GET \' | ||
| - | |||
| - | |||
| - | GET: | ||
| + | **GET: | ||
| + | ** | ||
| <WRAP center round box 95%> | <WRAP center round box 95%> | ||
| health status index | health status index | ||
| + | |||
| yellow open | yellow open | ||
| Line 63: | Line 70: | ||
| - | 2. Create a new index for the data, here we want to update mapping for: ' | + | **2. Create a new index for the data. In this example, we want to update mapping for: |
| - | + | ** | |
| - | (NOTE: | + | **RUN: |
| - | + | ** | |
| - | RUN: | + | <WRAP center round box 90%> |
| - | + | curl -X PUT \http:// | |
| - | curl -X PUT \ | + | |
| - | http:// | + | |
| - | -H ' | + | |
| - | -d '{ | + | |
| " | " | ||
| " | " | ||
| - | | + | " |
| " | " | ||
| }, | }, | ||
| Line 82: | Line 85: | ||
| } | } | ||
| } | } | ||
| - | |||
| } | } | ||
| }' | }' | ||
| + | </ | ||
| - | GET: | ||
| + | **GET: | ||
| + | ** | ||
| + | <WRAP center round box 90%> | ||
| {" | {" | ||
| + | </ | ||
| - | 3. Transfer data into new index? | ||
| - | |||
| - | RUN: | ||
| + | **3. Transfer data into new index, very important. | ||
| + | ** | ||
| + | **RUN (IF YOU CUT AND PASTE, REDUCE LINE SPACES, IMPORTANT): | ||
| + | ** | ||
| + | <WRAP center round box 90%> | ||
| curl -X POST \ | curl -X POST \ | ||
| http:// | http:// | ||
| Line 106: | Line 114: | ||
| } | } | ||
| }' | }' | ||
| + | </ | ||
| - | GET: | ||
| + | **GET: | ||
| + | ** | ||
| + | <WRAP center round box 90%> | ||
| {" | {" | ||
| + | </ | ||
| - | 4. Verify | + | **4. Verify |
| - | + | ** | |
| - | RUN: | + | **RUN: |
| + | ** | ||
| + | <WRAP center round box 90%> | ||
| curl -X GET \ | curl -X GET \ | ||
| Line 125: | Line 138: | ||
| } | } | ||
| }' | }' | ||
| + | </ | ||
| - | GET: | + | **5. Delete old index since the transfer in step 3 went well. Again, if the transfer failed, do not proceed, start over. |
| - | + | ** | |
| - | 5. Delete old index? | + | **RUN: |
| - | + | ** | |
| - | RUN: | + | <WRAP center round box 90%> |
| curl -X DELETE \ | curl -X DELETE \ | ||
| http:// | http:// | ||
| + | </ | ||
| - | + | **GET: | |
| - | GET: | + | ** |
| + | <WRAP center round box 80%> | ||
| {" | {" | ||
| + | </ | ||
| - | + | **6. Add new index finalized with an alias to the previous in case anything is specifically looking for the old key... which should not happen... but just to be safe. | |
| - | 6.1 Alias | + | ** |
| - | + | **RUN: | |
| - | RUN: | + | ** |
| - | + | <WRAP center round box 90%> | |
| - | curl -X POST \ | + | |
| - | http:// | + | |
| - | -d '{ | + | |
| - | " | + | |
| - | { | + | |
| - | " | + | |
| - | "index": " | + | |
| - | "alias": " | + | |
| - | } | + | |
| - | } | + | |
| - | ] | + | |
| - | }' | + | |
| - | + | ||
| - | + | ||
| - | GET: NOTE: DID NOT WORK!!! | + | |
| - | + | ||
| - | 6.2 | + | |
| - | + | ||
| - | RUN: | + | |
| curl -X POST \ | curl -X POST \ | ||
| http:// | http:// | ||
| Line 178: | Line 173: | ||
| ] | ] | ||
| }' | }' | ||
| + | </ | ||
| - | GET: | ||
| + | **GET: | ||
| + | ** | ||
| + | <WRAP center round box 90%> | ||
| {" | {" | ||
| + | </ | ||
| + | |||
| - | 6.3 ALL DONE! | + | **7. ALL DONE!** |
development/elasticsearch/elasticsearch.1639424960.txt.gz · Last modified: 2021/12/13 19:49 by slawrence