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 19:55] 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%>
 {"acknowledged":true,"shards_acknowledged":true,"index":"rdf_performance_2021-12_v3"} {"acknowledged":true,"shards_acknowledged":true,"index":"rdf_performance_2021-12_v3"}
  
 +</WRAP>
  
-3.  Transfer data into new index? 
- 
-RUN: 
  
 +**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 (IF YOU CUT AND PASTE, REDUCE LINE SPACES, IMPORTANT):
 +**
 +<WRAP center round box 90%>
 curl -X POST \ curl -X POST \
     http://localhost:9200/_reindex \     http://localhost:9200/_reindex \
Line 108: Line 114:
     }     }
 }' }'
 +</WRAP>
  
-GET: 
  
 +**GET:
 +**
 +<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":[]}
 +</WRAP>
  
  
-4.  Verify  (This step may be bad...?+**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%>
 curl -X GET \ curl -X GET \
  
Line 127: Line 138:
     }     }
 }' }'
 +</WRAP>
  
-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://localhost:9200/rdf_performance_2021-12 http://localhost:9200/rdf_performance_2021-12
 +</WRAP>
  
- +**GET: 
-GET: +** 
 +<WRAP center round box 80%>
 {"acknowledged":true} {"acknowledged":true}
 +</WRAP>
  
- +**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://localhost:9200/_aliases \ +
--d '{ +
-    "actions":+
-        { +
-            "remove":+
-                "index": "rdf_performance_2021-12_v2", +
-                "alias": "rdf_performance_2021-12" +
-            } +
-        } +
-    ] +
-}' +
- +
- +
-GET:  NOTE:  DID NOT WORK!!!  Maybe nothing to remove? +
- +
-6.2 +
- +
-RUN:   +
 curl -X POST \ curl -X POST \
 http://localhost:9200/_aliases \ http://localhost:9200/_aliases \
Line 180: Line 173:
     ]     ]
 }' }'
 +</WRAP>
  
-GET:  
  
 +**GET: 
 +**
 +<WRAP center round box 90%>
 {"acknowledged":true} {"acknowledged":true}
 +</WRAP>
 +
  
-6.ALL DONE!+**7. ALL DONE!**
development/elasticsearch/elasticsearch.1639425338.txt.gz · Last modified: 2021/12/13 19:55 by slawrence