User Tools

Site Tools


development:elasticsearch:elasticsearch

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
development:elasticsearch:elasticsearch [2021/12/13 20:00] slawrencedevelopment:elasticsearch:elasticsearch [2021/12/16 07:15] (current) slawrence
Line 1: Line 1:
 __**Re-Index ElasticSearch**__ __**Re-Index ElasticSearch**__
 +
 +REF: https://www.thirdrocktechkno.com/blog/6-steps-to-reindex-elasticsearch-data/
  
 There are potentially several situations where you may need to recreate the current Elastic Search index.  This article is being written to handle one of the most common causes related to field data-type mapping. There are potentially several situations where you may need to recreate the current Elastic Search index.  This article is being written to handle one of the most common causes related to field data-type mapping.
Line 15: 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.  Commands to perform this can be executed in a terminal connected to the 'esk' server instance, or wherever elasticsearch is running for the affected environment. 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.  Commands to perform this can be executed in a terminal connected to the 'esk' server instance, or wherever elasticsearch is running for the affected environment.
  
-To begin, log into the server running elasticsearch via SSH in a termanal window (i.e. newtowerqaesk1.err or the like).  Then: +**To begin, log into the server running elasticsearch via SSH in a termanal window (i.e. newtowerqaesk1.err or the like).  Then: 
- +** 
-1.  Retrieve existing indices: +**1.  Retrieve existing indices: 
- +** 
-RUN: +**RUN: 
 +**
 <WRAP center round box 80%> <WRAP center round box 80%>
-curl -X GET \'http://localhost:9200/_cat/indices/%2A?v=&s=index:desc' \+curl -X GET 'http://localhost:9200/_cat/indices/%2A?v=&s=index:desc'
 </WRAP> </WRAP>
  
  
-GET: +**GET: 
 +**
 <WRAP center round box 95%> <WRAP center round box 95%>
 health status index                     uuid                   pri rep docs.count docs.deleted store.size pri.store.size health status index                     uuid                   pri rep docs.count docs.deleted store.size pri.store.size
Line 68: Line 70:
  
  
-2.  Create a new index for the data. In this example, we want to update mapping for:  **'parameters.winlink1000OduAirSesState.currentValue'** and **'parameters.winlink1000OduAirSesState.newValue'**. +**2.  Create a new index for the data. In this example, we want to update mapping for:  **'parameters.winlink1000OduAirSesState.currentValue'** and **'parameters.winlink1000OduAirSesState.newValue'**. 
- +** 
-RUN:  +**RUN:  
 +**
 <WRAP center round box 90%> <WRAP center round box 90%>
 curl -X PUT \http://localhost:9200/rdf_performance_2021-12_v2 \-H 'Content-Type: application/json' \-d '{ curl -X PUT \http://localhost:9200/rdf_performance_2021-12_v2 \-H 'Content-Type: application/json' \-d '{
Line 88: Line 90:
  
  
-GET: +**GET: 
 +**
 <WRAP center round box 90%> <WRAP center round box 90%>
 {"acknowledged":true,"shards_acknowledged":true,"index":"rdf_performance_2021-12_v3"} {"acknowledged":true,"shards_acknowledged":true,"index":"rdf_performance_2021-12_v3"}
Line 96: Line 98:
  
  
-3.  Transfer data into new index, very important.  Do not proceed if this step fails.  If it does for any reason, start over again with a new index name to transfer to. +**3.  Transfer data into new index, very important.  Do not proceed if this step fails.  If it does for any reason, start over again with a new index name to transfer to. 
- +** 
-RUN: +**RUN (IF YOU CUT AND PASTE, REDUCE LINE SPACES, IMPORTANT)
 +**
 <WRAP center round box 90%> <WRAP center round box 90%>
 curl -X POST \ curl -X POST \
Line 115: Line 117:
  
  
-GET: +**GET: 
 +**
 <WRAP center round box 90%> <WRAP center round box 90%>
 {"took":927,"timed_out":false,"total":638,"updated":0,"created":638,"deleted":0,"batches":1,"version_conflicts":0,"noops":0,"retries":{"bulk":0,"search":0},"throttled_millis":0,"requests_per_second":-1.0,"throttled_until_millis":0,"failures":[]} {"took":927,"timed_out":false,"total":638,"updated":0,"created":638,"deleted":0,"batches":1,"version_conflicts":0,"noops":0,"retries":{"bulk":0,"search":0},"throttled_millis":0,"requests_per_second":-1.0,"throttled_until_millis":0,"failures":[]}
Line 122: Line 124:
  
  
-4.  Verify  (This step does not always work for some reason, though it is ok if it fails) +**4.  Verify  (This step does not always work for some reason, though it is ok if it fails) 
- +** 
-RUN: +**RUN: 
 +**
 <WRAP center round box 90%> <WRAP center round box 90%>
 curl -X GET \ curl -X GET \
Line 138: Line 140:
 </WRAP> </WRAP>
  
-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 since the transfer in step 3 went well.  Again, if the transfer failed, do not proceed, start over. 
- +** 
-RUN: +**RUN: 
 +**
 <WRAP center round box 90%> <WRAP center round box 90%>
 curl -X DELETE \ curl -X DELETE \
Line 147: Line 149:
 </WRAP> </WRAP>
  
-GET: +**GET: 
 +**
 <WRAP center round box 80%> <WRAP center round box 80%>
 {"acknowledged":true} {"acknowledged":true}
 </WRAP> </WRAP>
  
-6.1   +**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. 
- +** 
-RUN:   +**RUN:   
 +**
 <WRAP center round box 90%> <WRAP center round box 90%>
 curl -X POST \ curl -X POST \
Line 174: Line 176:
  
  
-GET:  +**GET:  
 +**
 <WRAP center round box 90%> <WRAP center round box 90%>
 {"acknowledged":true} {"acknowledged":true}
Line 181: Line 183:
  
  
-6.ALL DONE!+**7. ALL DONE!**
development/elasticsearch/elasticsearch.1639425624.txt.gz · Last modified: 2021/12/13 20:00 by slawrence