<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.archivematica.org/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Mamedin</id>
	<title>Archivematica - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.archivematica.org/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Mamedin"/>
	<link rel="alternate" type="text/html" href="https://wiki.archivematica.org/Special:Contributions/Mamedin"/>
	<updated>2026-06-03T05:07:57Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.35.4</generator>
	<entry>
		<id>https://wiki.archivematica.org/index.php?title=Update_mapping_and_reindex_Elasticsearch_indices&amp;diff=13533</id>
		<title>Update mapping and reindex Elasticsearch indices</title>
		<link rel="alternate" type="text/html" href="https://wiki.archivematica.org/index.php?title=Update_mapping_and_reindex_Elasticsearch_indices&amp;diff=13533"/>
		<updated>2020-12-23T21:25:49Z</updated>

		<summary type="html">&lt;p&gt;Mamedin: /* Run script to reindex and use new mappings */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Backup Elasticsearch data =&lt;br /&gt;
&lt;br /&gt;
The easiest way to backup the Elasticsearch data is copying the data directory:&lt;br /&gt;
&lt;br /&gt;
  sudo service elasticsearch stop&lt;br /&gt;
  tar cvfz var_lib_elasticsearch.tgz /var/lib/elasticsearch&lt;br /&gt;
  sudo service elasticsearch start&lt;br /&gt;
&lt;br /&gt;
= List indices to resize the Elasticsearch heap size when needed =&lt;br /&gt;
&lt;br /&gt;
Use the following command to list indices:&lt;br /&gt;
&lt;br /&gt;
  curl -s -X GET 'http://localhost:9200/_cat/indices/%2A?v=&amp;amp;s=index:desc'&lt;br /&gt;
&lt;br /&gt;
The output should show something like this:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
  root@archivematica-test-server:~# curl -s -X GET 'http://localhost:9200/_cat/indices/%2A?v=&amp;amp;s=index:desc'&lt;br /&gt;
  health status index         uuid                   pri rep docs.count docs.deleted store.size pri.store.size&lt;br /&gt;
  yellow open   transfers     lYqkYjwZRy2XG8CP_3S3PQ   5   1          0            0      1.2kb          1.2kb&lt;br /&gt;
  yellow open   transferfiles K5gnDZyOQz2JdIeZ6adJsQ   5   1          0            0      1.2kb          1.2kb&lt;br /&gt;
  yellow open   aips          yAyK_koXThaZcWsBYfzN7w   5   1         17            0    101.4mb        101.4mb&lt;br /&gt;
  yellow open   aipfiles      TVrrX8jkRhWWxGfvK_M6zg   5   1      11987            0      2.9gb          2.9gb&lt;br /&gt;
&lt;br /&gt;
Take the elasticsearch heap size from ''/etc/default/elasticsearch'' (Ubuntu) or ''/etc/sysconfig/elasticsearch'' (CentOS):&lt;br /&gt;
&lt;br /&gt;
  root@ny-gclibrary-test-release-1:~# grep ES_JAVA_OPTS= /etc/default/elasticsearch &lt;br /&gt;
  #ES_JAVA_OPTS=&lt;br /&gt;
  ES_JAVA_OPTS=&amp;quot;-Xms2g -Xmx2g&amp;quot;&lt;br /&gt;
&lt;br /&gt;
The heap size for the example is 2G.&lt;br /&gt;
&lt;br /&gt;
Ensure your Elasticsearch heap size is greater than the max ''store.size'' in the indices list. For our example, it should be greater than 3GB. &lt;br /&gt;
&lt;br /&gt;
* Edit ''/etc/default/elasticsearch'' or ''/etc/sysconfig/elasticsearch''.&lt;br /&gt;
* Change ''ES_JAVA_OPTS'' to a bigger value, in our example: &lt;br /&gt;
  ES_JAVA_OPTS=&amp;quot;-Xms3g -Xmx3g&amp;quot;.&lt;br /&gt;
* Restart Elasticsearch service for the changes to take effect (''sudo service elasticsearch restart'')&lt;br /&gt;
&lt;br /&gt;
= Run script to reindex and use new mappings =&lt;br /&gt;
&lt;br /&gt;
Use the following script:&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;&lt;br /&gt;
#!/bin/bash&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
es_url=&amp;quot;http://localhost:9200&amp;quot;&lt;br /&gt;
&lt;br /&gt;
index_list='aips aipfiles transfers transferfiles'&lt;br /&gt;
&lt;br /&gt;
echo -e &amp;quot;\nIndex list before reindexing:\n&amp;quot;&lt;br /&gt;
curl -s -X GET &amp;quot;${es_url}/_cat/indices/%2A?v=&amp;amp;s=index:desc&amp;quot;&lt;br /&gt;
echo -e &amp;quot;\n&amp;quot;&lt;br /&gt;
&lt;br /&gt;
#Clone indices with _reindex API call:&lt;br /&gt;
for index in $index_list;do &lt;br /&gt;
    echo &amp;quot;Reindex ${index} in ${index}_new...&amp;quot;&lt;br /&gt;
    curl -s -X POST \&lt;br /&gt;
      ${es_url}/_reindex \&lt;br /&gt;
      -H 'Content-Type: application/json' \&lt;br /&gt;
      -d '{&lt;br /&gt;
      &amp;quot;source&amp;quot;: {&lt;br /&gt;
        &amp;quot;index&amp;quot;: &amp;quot;'&amp;quot;${index}&amp;quot;'&amp;quot;&lt;br /&gt;
      },&lt;br /&gt;
      &amp;quot;dest&amp;quot;: {&lt;br /&gt;
        &amp;quot;index&amp;quot;: &amp;quot;'&amp;quot;${index}_new&amp;quot;'&amp;quot;&lt;br /&gt;
      }&lt;br /&gt;
    }' &amp;gt; /dev/null&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
echo -e &amp;quot;\n\n&amp;quot;&lt;br /&gt;
&lt;br /&gt;
echo -e &amp;quot;Index list after tmp indices creation\n&amp;quot;&lt;br /&gt;
indices_output=$(curl -s -X GET &amp;quot;${es_url}/_cat/indices/%2A?v=&amp;amp;s=index:desc&amp;quot;)&lt;br /&gt;
curl -s -X GET &amp;quot;${es_url}/_cat/indices/%2A?v=&amp;amp;s=index:desc&amp;quot;&lt;br /&gt;
echo -e &amp;quot;\n&amp;quot;&lt;br /&gt;
&lt;br /&gt;
#Delete old indices&lt;br /&gt;
for index in $index_list;do&lt;br /&gt;
  echo &amp;quot;Deleting ${index}...&amp;quot;&lt;br /&gt;
  curl -s -X DELETE ${es_url}/${index} &amp;gt; /dev/null&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
#Restart archivematica-dashboard to create indices with new mappings&lt;br /&gt;
echo -e &amp;quot;\nRestarting archivematica-dashboard&amp;quot;&lt;br /&gt;
sudo service archivematica-dashboard restart&lt;br /&gt;
&lt;br /&gt;
#Wait 30 seconds&lt;br /&gt;
echo &amp;quot;Wait 30 seconds to ensure dashboard has created the empty indices with new mapping&amp;quot;&lt;br /&gt;
sleep 30&lt;br /&gt;
echo -e &amp;quot;\n&amp;quot;&lt;br /&gt;
&lt;br /&gt;
#When index has no docs the reindex doesn't create the new index (typically transferfiles index)&lt;br /&gt;
#There's a check to ensure the new index has been create before reindexing. &lt;br /&gt;
#Reindex fron *_new indices:&lt;br /&gt;
for index in $index_list;do&lt;br /&gt;
  if echo &amp;quot;$indices_output&amp;quot; | grep ${index}_new &amp;gt;/dev/null; then&lt;br /&gt;
    echo &amp;quot;Indexing ${index} using ${index}_new ...&amp;quot;&lt;br /&gt;
    curl -s -X POST \&lt;br /&gt;
      ${es_url}/_reindex \&lt;br /&gt;
      -H 'Content-Type: application/json' \&lt;br /&gt;
      -d '{&lt;br /&gt;
      &amp;quot;source&amp;quot;: {&lt;br /&gt;
        &amp;quot;index&amp;quot;: &amp;quot;'&amp;quot;${index}_new&amp;quot;'&amp;quot;&lt;br /&gt;
      },&lt;br /&gt;
      &amp;quot;dest&amp;quot;: {&lt;br /&gt;
        &amp;quot;index&amp;quot;: &amp;quot;'&amp;quot;${index}&amp;quot;'&amp;quot;&lt;br /&gt;
      }&lt;br /&gt;
    }' &amp;gt; /dev/null&lt;br /&gt;
  fi&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
echo -e &amp;quot;\n&amp;quot;&lt;br /&gt;
&lt;br /&gt;
#Delete tmp indices&lt;br /&gt;
for index in $index_list;do&lt;br /&gt;
  if echo &amp;quot;$indices_output&amp;quot; | grep ${index}_new &amp;gt;/dev/null; then&lt;br /&gt;
     echo &amp;quot;Deleting ${index}_new...&amp;quot;&lt;br /&gt;
     curl -s -X DELETE ${es_url}/${index}_new &amp;gt; /dev/null&lt;br /&gt;
  fi&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
echo -e &amp;quot;\n\nReindexing done:\n&amp;quot;&lt;br /&gt;
curl -s -X GET &amp;quot;${es_url}/_cat/indices/%2A?v=&amp;amp;s=index:desc&amp;quot;&lt;br /&gt;
echo -e &amp;quot;\n&amp;quot;&lt;br /&gt;
&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For our example it takes 11 minutes, and this is the output:&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;&lt;br /&gt;
root@archivematica-test-server:~# time ./script_reindex_new_map.sh &lt;br /&gt;
&lt;br /&gt;
Index list before reindexing:&lt;br /&gt;
&lt;br /&gt;
health status index         uuid                   pri rep docs.count docs.deleted store.size pri.store.size&lt;br /&gt;
yellow open   transfers     lYqkYjwZRy2XG8CP_3S3PQ   5   1          3            0     11.6kb         11.6kb&lt;br /&gt;
yellow open   transferfiles K5gnDZyOQz2JdIeZ6adJsQ   5   1          0            0      1.2kb          1.2kb&lt;br /&gt;
yellow open   aips          yAyK_koXThaZcWsBYfzN7w   5   1         17            0    101.4mb        101.4mb&lt;br /&gt;
yellow open   aipfiles      TVrrX8jkRhWWxGfvK_M6zg   5   1      12905            0      2.6gb          2.6gb&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Reindex aips in aips_new...&lt;br /&gt;
Reindex aipfiles in aipfiles_new...&lt;br /&gt;
Reindex transfers in transfers_new...&lt;br /&gt;
Reindex transferfiles in transferfiles_new...&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Index list after tmp indices creation&lt;br /&gt;
&lt;br /&gt;
health status index         uuid                   pri rep docs.count docs.deleted store.size pri.store.size&lt;br /&gt;
yellow open   transfers_new gdFevH8yRdiNTdrPcfo8Lg   5   1          0            0       460b           460b&lt;br /&gt;
yellow open   transfers     lYqkYjwZRy2XG8CP_3S3PQ   5   1          3            0     11.6kb         11.6kb&lt;br /&gt;
yellow open   transferfiles K5gnDZyOQz2JdIeZ6adJsQ   5   1          0            0      1.2kb          1.2kb&lt;br /&gt;
yellow open   aips_new      uJ-ehaYLTfe_1lOSErfu3Q   5   1         17            0     96.8mb         96.8mb&lt;br /&gt;
yellow open   aips          yAyK_koXThaZcWsBYfzN7w   5   1         17            0    101.4mb        101.4mb&lt;br /&gt;
yellow open   aipfiles_new  00Xxu7v2QvWsq92gM247xQ   5   1      12905            0      3.1gb          3.1gb&lt;br /&gt;
yellow open   aipfiles      TVrrX8jkRhWWxGfvK_M6zg   5   1      12905            0      2.6gb          2.6gb&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Deleting aips...&lt;br /&gt;
Deleting aipfiles...&lt;br /&gt;
Deleting transfers...&lt;br /&gt;
Deleting transferfiles...&lt;br /&gt;
&lt;br /&gt;
Restarting archivematica-dashboard&lt;br /&gt;
Wait 30 seconds to ensure dashboard has created the empty indices with new mapping&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Indexing aips using aips_new ...&lt;br /&gt;
Indexing aipfiles using aipfiles_new ...&lt;br /&gt;
Indexing transfers using transfers_new ...&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Deleting aips_new...&lt;br /&gt;
Deleting aipfiles_new...&lt;br /&gt;
Deleting transfers_new...&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Reindexing done:&lt;br /&gt;
&lt;br /&gt;
health status index         uuid                   pri rep docs.count docs.deleted store.size pri.store.size&lt;br /&gt;
yellow open   transfers     FC7aSVPmSmmCc_LTv1AQRA   5   1          3            0      1.2kb          1.2kb&lt;br /&gt;
yellow open   transferfiles 5JMAft3FQwmosZQFi7eJNw   5   1          0            0      1.2kb          1.2kb&lt;br /&gt;
yellow open   aips          EtwXG3-4SO2Px-4QMRufXA   5   1         17            0    102.1mb        102.1mb&lt;br /&gt;
yellow open   aipfiles      -PFuzslgTeWJ4CWny8VZoA   5   1      12905            0        3gb            3gb&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
real	10m47.114s&lt;br /&gt;
user	0m0.068s&lt;br /&gt;
sys	0m0.032s&lt;br /&gt;
&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''NOTE''':  The script could fail because JAVA heap size out of memory (please, check /var/log/elascticsearch.log). In this case the indices will be empty, so restore /var/lib/elasticsearch from backup, increase Elasticsearch JAVA heap size and try again.&lt;br /&gt;
&lt;br /&gt;
The script uses the elasticsearch API and makes the following actions:&lt;br /&gt;
&lt;br /&gt;
* Reindex the ''transfers'', ''transferfiles'', ''aips'' and ''aipfiles'' indices in new temporary indices&lt;br /&gt;
* Delete original indices&lt;br /&gt;
* Restart ''archivematica-dashboard'' service to create empty indices with new mappings&lt;br /&gt;
* Reindex from temporary indices&lt;br /&gt;
* Delete temporary indices&lt;br /&gt;
&lt;br /&gt;
= Restore Elasticsearch heap size when needed=&lt;br /&gt;
&lt;br /&gt;
* Edit ''/etc/default/elasticsearch'' or ''/etc/sysconfig/elasticsearch'' when needed.&lt;br /&gt;
* Change ''ES_JAVA_OPTS'' when needed.&lt;br /&gt;
* Restart Elasticsearch service when needed (''sudo service elasticsearch restart'')&lt;/div&gt;</summary>
		<author><name>Mamedin</name></author>
	</entry>
	<entry>
		<id>https://wiki.archivematica.org/index.php?title=Update_mapping_and_reindex_Elasticsearch_indices&amp;diff=13532</id>
		<title>Update mapping and reindex Elasticsearch indices</title>
		<link rel="alternate" type="text/html" href="https://wiki.archivematica.org/index.php?title=Update_mapping_and_reindex_Elasticsearch_indices&amp;diff=13532"/>
		<updated>2020-12-23T21:25:14Z</updated>

		<summary type="html">&lt;p&gt;Mamedin: /* Run script to reindex and use new mappings */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Backup Elasticsearch data =&lt;br /&gt;
&lt;br /&gt;
The easiest way to backup the Elasticsearch data is copying the data directory:&lt;br /&gt;
&lt;br /&gt;
  sudo service elasticsearch stop&lt;br /&gt;
  tar cvfz var_lib_elasticsearch.tgz /var/lib/elasticsearch&lt;br /&gt;
  sudo service elasticsearch start&lt;br /&gt;
&lt;br /&gt;
= List indices to resize the Elasticsearch heap size when needed =&lt;br /&gt;
&lt;br /&gt;
Use the following command to list indices:&lt;br /&gt;
&lt;br /&gt;
  curl -s -X GET 'http://localhost:9200/_cat/indices/%2A?v=&amp;amp;s=index:desc'&lt;br /&gt;
&lt;br /&gt;
The output should show something like this:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
  root@archivematica-test-server:~# curl -s -X GET 'http://localhost:9200/_cat/indices/%2A?v=&amp;amp;s=index:desc'&lt;br /&gt;
  health status index         uuid                   pri rep docs.count docs.deleted store.size pri.store.size&lt;br /&gt;
  yellow open   transfers     lYqkYjwZRy2XG8CP_3S3PQ   5   1          0            0      1.2kb          1.2kb&lt;br /&gt;
  yellow open   transferfiles K5gnDZyOQz2JdIeZ6adJsQ   5   1          0            0      1.2kb          1.2kb&lt;br /&gt;
  yellow open   aips          yAyK_koXThaZcWsBYfzN7w   5   1         17            0    101.4mb        101.4mb&lt;br /&gt;
  yellow open   aipfiles      TVrrX8jkRhWWxGfvK_M6zg   5   1      11987            0      2.9gb          2.9gb&lt;br /&gt;
&lt;br /&gt;
Take the elasticsearch heap size from ''/etc/default/elasticsearch'' (Ubuntu) or ''/etc/sysconfig/elasticsearch'' (CentOS):&lt;br /&gt;
&lt;br /&gt;
  root@ny-gclibrary-test-release-1:~# grep ES_JAVA_OPTS= /etc/default/elasticsearch &lt;br /&gt;
  #ES_JAVA_OPTS=&lt;br /&gt;
  ES_JAVA_OPTS=&amp;quot;-Xms2g -Xmx2g&amp;quot;&lt;br /&gt;
&lt;br /&gt;
The heap size for the example is 2G.&lt;br /&gt;
&lt;br /&gt;
Ensure your Elasticsearch heap size is greater than the max ''store.size'' in the indices list. For our example, it should be greater than 3GB. &lt;br /&gt;
&lt;br /&gt;
* Edit ''/etc/default/elasticsearch'' or ''/etc/sysconfig/elasticsearch''.&lt;br /&gt;
* Change ''ES_JAVA_OPTS'' to a bigger value, in our example: &lt;br /&gt;
  ES_JAVA_OPTS=&amp;quot;-Xms3g -Xmx3g&amp;quot;.&lt;br /&gt;
* Restart Elasticsearch service for the changes to take effect (''sudo service elasticsearch restart'')&lt;br /&gt;
&lt;br /&gt;
= Run script to reindex and use new mappings =&lt;br /&gt;
&lt;br /&gt;
Use the following script:&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;&lt;br /&gt;
#!/bin/bash&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
es_url=&amp;quot;http://localhost:9200&amp;quot;&lt;br /&gt;
&lt;br /&gt;
index_list='aips aipfiles transfers transferfiles'&lt;br /&gt;
&lt;br /&gt;
echo -e &amp;quot;\nIndex list before reindexing:\n&amp;quot;&lt;br /&gt;
curl -s -X GET &amp;quot;${es_url}/_cat/indices/%2A?v=&amp;amp;s=index:desc&amp;quot;&lt;br /&gt;
echo -e &amp;quot;\n&amp;quot;&lt;br /&gt;
&lt;br /&gt;
#Clone indices with _reindex API call:&lt;br /&gt;
for index in $index_list;do &lt;br /&gt;
    echo &amp;quot;Reindex ${index} in ${index}_new...&amp;quot;&lt;br /&gt;
    curl -s -X POST \&lt;br /&gt;
      ${es_url}/_reindex \&lt;br /&gt;
      -H 'Content-Type: application/json' \&lt;br /&gt;
      -d '{&lt;br /&gt;
      &amp;quot;source&amp;quot;: {&lt;br /&gt;
        &amp;quot;index&amp;quot;: &amp;quot;'&amp;quot;${index}&amp;quot;'&amp;quot;&lt;br /&gt;
      },&lt;br /&gt;
      &amp;quot;dest&amp;quot;: {&lt;br /&gt;
        &amp;quot;index&amp;quot;: &amp;quot;'&amp;quot;${index}_new&amp;quot;'&amp;quot;&lt;br /&gt;
      }&lt;br /&gt;
    }' &amp;gt; /dev/null&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
echo -e &amp;quot;\n\n&amp;quot;&lt;br /&gt;
&lt;br /&gt;
echo -e &amp;quot;Index list after tmp indices creation\n&amp;quot;&lt;br /&gt;
indices_output=$(curl -s -X GET &amp;quot;${es_url}/_cat/indices/%2A?v=&amp;amp;s=index:desc&amp;quot;)&lt;br /&gt;
curl -s -X GET &amp;quot;${es_url}/_cat/indices/%2A?v=&amp;amp;s=index:desc&amp;quot;&lt;br /&gt;
echo -e &amp;quot;\n&amp;quot;&lt;br /&gt;
&lt;br /&gt;
#Delete old indices&lt;br /&gt;
for index in $index_list;do&lt;br /&gt;
  echo &amp;quot;Deleting ${index}...&amp;quot;&lt;br /&gt;
  curl -s -X DELETE ${es_url}/${index} &amp;gt; /dev/null&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
#Restart archivematica-dashboard to create indices with new mappings&lt;br /&gt;
echo -e &amp;quot;\nRestarting archivematica-dashboard&amp;quot;&lt;br /&gt;
sudo service archivematica-dashboard restart&lt;br /&gt;
&lt;br /&gt;
#Wait 30 seconds&lt;br /&gt;
echo &amp;quot;Wait 30 seconds to ensure dashboard has created the empty indices with new mapping&amp;quot;&lt;br /&gt;
sleep 30&lt;br /&gt;
echo -e &amp;quot;\n&amp;quot;&lt;br /&gt;
&lt;br /&gt;
#When index has no docs the reindex doesn't create the new index (typically transferfiles index)&lt;br /&gt;
#There's a check to ensure the new index has been create before reindexing. &lt;br /&gt;
#Reindex fron *_new indices:&lt;br /&gt;
for index in $index_list;do&lt;br /&gt;
  if echo &amp;quot;$indices_output&amp;quot; | grep ${index}_new &amp;gt;/dev/null; then&lt;br /&gt;
    echo &amp;quot;Indexing ${index} using ${index}_new ...&amp;quot;&lt;br /&gt;
    curl -s -X POST \&lt;br /&gt;
      ${es_url}/_reindex \&lt;br /&gt;
      -H 'Content-Type: application/json' \&lt;br /&gt;
      -d '{&lt;br /&gt;
      &amp;quot;source&amp;quot;: {&lt;br /&gt;
        &amp;quot;index&amp;quot;: &amp;quot;'&amp;quot;${index}_new&amp;quot;'&amp;quot;&lt;br /&gt;
      },&lt;br /&gt;
      &amp;quot;dest&amp;quot;: {&lt;br /&gt;
        &amp;quot;index&amp;quot;: &amp;quot;'&amp;quot;${index}&amp;quot;'&amp;quot;&lt;br /&gt;
      }&lt;br /&gt;
    }' &amp;gt; /dev/null&lt;br /&gt;
  fi&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
echo -e &amp;quot;\n&amp;quot;&lt;br /&gt;
&lt;br /&gt;
#Delete tmp indices&lt;br /&gt;
for index in $index_list;do&lt;br /&gt;
  if echo &amp;quot;$indices_output&amp;quot; | grep ${index}_new &amp;gt;/dev/null; then&lt;br /&gt;
     echo &amp;quot;Deleting ${index}_new...&amp;quot;&lt;br /&gt;
     curl -s -X DELETE ${es_url}/${index}_new &amp;gt; /dev/null&lt;br /&gt;
  fi&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
echo -e &amp;quot;\n\nReindexing done:\n&amp;quot;&lt;br /&gt;
curl -s -X GET &amp;quot;${es_url}/_cat/indices/%2A?v=&amp;amp;s=index:desc&amp;quot;&lt;br /&gt;
echo -e &amp;quot;\n&amp;quot;&lt;br /&gt;
&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For our example it takes 11 minutes, and this is the output:&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;&lt;br /&gt;
root@archivematica-test-server:~# time ./script_reindex_new_map.sh &lt;br /&gt;
&lt;br /&gt;
Index list before reindexing:&lt;br /&gt;
&lt;br /&gt;
health status index         uuid                   pri rep docs.count docs.deleted store.size pri.store.size&lt;br /&gt;
yellow open   transfers     lYqkYjwZRy2XG8CP_3S3PQ   5   1          3            0     11.6kb         11.6kb&lt;br /&gt;
yellow open   transferfiles K5gnDZyOQz2JdIeZ6adJsQ   5   1          0            0      1.2kb          1.2kb&lt;br /&gt;
yellow open   aips          yAyK_koXThaZcWsBYfzN7w   5   1         17            0    101.4mb        101.4mb&lt;br /&gt;
yellow open   aipfiles      TVrrX8jkRhWWxGfvK_M6zg   5   1      12905            0      2.6gb          2.6gb&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Reindex aips in aips_new...&lt;br /&gt;
Reindex aipfiles in aipfiles_new...&lt;br /&gt;
Reindex transfers in transfers_new...&lt;br /&gt;
Reindex transferfiles in transferfiles_new...&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Index list after tmp indices creation&lt;br /&gt;
&lt;br /&gt;
health status index         uuid                   pri rep docs.count docs.deleted store.size pri.store.size&lt;br /&gt;
yellow open   transfers_new gdFevH8yRdiNTdrPcfo8Lg   5   1          0            0       460b           460b&lt;br /&gt;
yellow open   transfers     lYqkYjwZRy2XG8CP_3S3PQ   5   1          3            0     11.6kb         11.6kb&lt;br /&gt;
yellow open   transferfiles K5gnDZyOQz2JdIeZ6adJsQ   5   1          0            0      1.2kb          1.2kb&lt;br /&gt;
yellow open   aips_new      uJ-ehaYLTfe_1lOSErfu3Q   5   1         17            0     96.8mb         96.8mb&lt;br /&gt;
yellow open   aips          yAyK_koXThaZcWsBYfzN7w   5   1         17            0    101.4mb        101.4mb&lt;br /&gt;
yellow open   aipfiles_new  00Xxu7v2QvWsq92gM247xQ   5   1      12905            0      3.1gb          3.1gb&lt;br /&gt;
yellow open   aipfiles      TVrrX8jkRhWWxGfvK_M6zg   5   1      12905            0      2.6gb          2.6gb&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Deleting aips...&lt;br /&gt;
Deleting aipfiles...&lt;br /&gt;
Deleting transfers...&lt;br /&gt;
Deleting transferfiles...&lt;br /&gt;
&lt;br /&gt;
Restarting archivematica-dashboard&lt;br /&gt;
Wait 30 seconds to ensure dashboard has created the empty indices with new mapping&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Indexing aips using aips_new ...&lt;br /&gt;
Indexing aipfiles using aipfiles_new ...&lt;br /&gt;
Indexing transfers using transfers_new ...&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Deleting aips_new...&lt;br /&gt;
Deleting aipfiles_new...&lt;br /&gt;
Deleting transfers_new...&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Reindexing done:&lt;br /&gt;
&lt;br /&gt;
health status index         uuid                   pri rep docs.count docs.deleted store.size pri.store.size&lt;br /&gt;
yellow open   transfers     FC7aSVPmSmmCc_LTv1AQRA   5   1          3            0      1.2kb          1.2kb&lt;br /&gt;
yellow open   transferfiles 5JMAft3FQwmosZQFi7eJNw   5   1          0            0      1.2kb          1.2kb&lt;br /&gt;
yellow open   aips          EtwXG3-4SO2Px-4QMRufXA   5   1         17            0    102.1mb        102.1mb&lt;br /&gt;
yellow open   aipfiles      -PFuzslgTeWJ4CWny8VZoA   5   1      12905            0        3gb            3gb&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
real	10m47.114s&lt;br /&gt;
user	0m0.068s&lt;br /&gt;
sys	0m0.032s&lt;br /&gt;
&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
**NOTE**:  The script could fail because JAVA heap size out of memory (pleease, check /var/log/elascticsearch.log). In this case the indices will be empty, so restore /var/lib/elasticsearch from backup, increase Elasticsearch JAVA heap size and try again.&lt;br /&gt;
&lt;br /&gt;
The script uses the elasticsearch API and makes the following actions:&lt;br /&gt;
&lt;br /&gt;
* Reindex the ''transfers'', ''transferfiles'', ''aips'' and ''aipfiles'' indices in new temporary indices&lt;br /&gt;
* Delete original indices&lt;br /&gt;
* Restart ''archivematica-dashboard'' service to create empty indices with new mappings&lt;br /&gt;
* Reindex from temporary indices&lt;br /&gt;
* Delete temporary indices&lt;br /&gt;
&lt;br /&gt;
= Restore Elasticsearch heap size when needed=&lt;br /&gt;
&lt;br /&gt;
* Edit ''/etc/default/elasticsearch'' or ''/etc/sysconfig/elasticsearch'' when needed.&lt;br /&gt;
* Change ''ES_JAVA_OPTS'' when needed.&lt;br /&gt;
* Restart Elasticsearch service when needed (''sudo service elasticsearch restart'')&lt;/div&gt;</summary>
		<author><name>Mamedin</name></author>
	</entry>
	<entry>
		<id>https://wiki.archivematica.org/index.php?title=Update_mapping_and_reindex_Elasticsearch_indices&amp;diff=13530</id>
		<title>Update mapping and reindex Elasticsearch indices</title>
		<link rel="alternate" type="text/html" href="https://wiki.archivematica.org/index.php?title=Update_mapping_and_reindex_Elasticsearch_indices&amp;diff=13530"/>
		<updated>2020-12-21T16:49:20Z</updated>

		<summary type="html">&lt;p&gt;Mamedin: /* Run script to reindex and use new mappings */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Backup Elasticsearch data =&lt;br /&gt;
&lt;br /&gt;
The easiest way to backup the Elasticsearch data is copying the data directory:&lt;br /&gt;
&lt;br /&gt;
  sudo service elasticsearch stop&lt;br /&gt;
  tar cvfz var_lib_elasticsearch.tgz /var/lib/elasticsearch&lt;br /&gt;
  sudo service elasticsearch start&lt;br /&gt;
&lt;br /&gt;
= List indices to resize the Elasticsearch heap size when needed =&lt;br /&gt;
&lt;br /&gt;
Use the following command to list indices:&lt;br /&gt;
&lt;br /&gt;
  curl -s -X GET 'http://localhost:9200/_cat/indices/%2A?v=&amp;amp;s=index:desc'&lt;br /&gt;
&lt;br /&gt;
The output should show something like this:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
  root@archivematica-test-server:~# curl -s -X GET 'http://localhost:9200/_cat/indices/%2A?v=&amp;amp;s=index:desc'&lt;br /&gt;
  health status index         uuid                   pri rep docs.count docs.deleted store.size pri.store.size&lt;br /&gt;
  yellow open   transfers     lYqkYjwZRy2XG8CP_3S3PQ   5   1          0            0      1.2kb          1.2kb&lt;br /&gt;
  yellow open   transferfiles K5gnDZyOQz2JdIeZ6adJsQ   5   1          0            0      1.2kb          1.2kb&lt;br /&gt;
  yellow open   aips          yAyK_koXThaZcWsBYfzN7w   5   1         17            0    101.4mb        101.4mb&lt;br /&gt;
  yellow open   aipfiles      TVrrX8jkRhWWxGfvK_M6zg   5   1      11987            0      2.9gb          2.9gb&lt;br /&gt;
&lt;br /&gt;
Take the elasticsearch heap size from ''/etc/default/elasticsearch'' (Ubuntu) or ''/etc/sysconfig/elasticsearch'' (CentOS):&lt;br /&gt;
&lt;br /&gt;
  root@ny-gclibrary-test-release-1:~# grep ES_JAVA_OPTS= /etc/default/elasticsearch &lt;br /&gt;
  #ES_JAVA_OPTS=&lt;br /&gt;
  ES_JAVA_OPTS=&amp;quot;-Xms2g -Xmx2g&amp;quot;&lt;br /&gt;
&lt;br /&gt;
The heap size for the example is 2G.&lt;br /&gt;
&lt;br /&gt;
Ensure your Elasticsearch heap size is greater than the max ''store.size'' in the indices list. For our example, it should be greater than 3GB. &lt;br /&gt;
&lt;br /&gt;
* Edit ''/etc/default/elasticsearch'' or ''/etc/sysconfig/elasticsearch'' when needed.&lt;br /&gt;
* Change ''ES_JAVA_OPTS'' when needed.&lt;br /&gt;
* Restart Elasticsearch service when needed (''sudo service elasticsearch restart'')&lt;br /&gt;
&lt;br /&gt;
= Run script to reindex and use new mappings =&lt;br /&gt;
&lt;br /&gt;
Use the following script:&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;&lt;br /&gt;
#!/bin/bash&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
es_url=&amp;quot;http://localhost:9200&amp;quot;&lt;br /&gt;
&lt;br /&gt;
index_list='aips aipfiles transfers transferfiles'&lt;br /&gt;
&lt;br /&gt;
echo -e &amp;quot;\nIndex list before reindexing:\n&amp;quot;&lt;br /&gt;
curl -s -X GET &amp;quot;${es_url}/_cat/indices/%2A?v=&amp;amp;s=index:desc&amp;quot;&lt;br /&gt;
echo -e &amp;quot;\n&amp;quot;&lt;br /&gt;
&lt;br /&gt;
#Clone indices with _reindex API call:&lt;br /&gt;
for index in $index_list;do &lt;br /&gt;
    echo &amp;quot;Reindex ${index} in ${index}_new...&amp;quot;&lt;br /&gt;
    curl -s -X POST \&lt;br /&gt;
      ${es_url}/_reindex \&lt;br /&gt;
      -H 'Content-Type: application/json' \&lt;br /&gt;
      -d '{&lt;br /&gt;
      &amp;quot;source&amp;quot;: {&lt;br /&gt;
        &amp;quot;index&amp;quot;: &amp;quot;'&amp;quot;${index}&amp;quot;'&amp;quot;&lt;br /&gt;
      },&lt;br /&gt;
      &amp;quot;dest&amp;quot;: {&lt;br /&gt;
        &amp;quot;index&amp;quot;: &amp;quot;'&amp;quot;${index}_new&amp;quot;'&amp;quot;&lt;br /&gt;
      }&lt;br /&gt;
    }' &amp;gt; /dev/null&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
echo -e &amp;quot;\n\n&amp;quot;&lt;br /&gt;
&lt;br /&gt;
echo -e &amp;quot;Index list after tmp indices creation\n&amp;quot;&lt;br /&gt;
indices_output=$(curl -s -X GET &amp;quot;${es_url}/_cat/indices/%2A?v=&amp;amp;s=index:desc&amp;quot;)&lt;br /&gt;
curl -s -X GET &amp;quot;${es_url}/_cat/indices/%2A?v=&amp;amp;s=index:desc&amp;quot;&lt;br /&gt;
echo -e &amp;quot;\n&amp;quot;&lt;br /&gt;
&lt;br /&gt;
#Delete old indices&lt;br /&gt;
for index in $index_list;do&lt;br /&gt;
  echo &amp;quot;Deleting ${index}...&amp;quot;&lt;br /&gt;
  curl -s -X DELETE ${es_url}/${index} &amp;gt; /dev/null&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
#Restart archivematica-dashboard to create indices with new mappings&lt;br /&gt;
echo -e &amp;quot;\nRestarting archivematica-dashboard&amp;quot;&lt;br /&gt;
sudo service archivematica-dashboard restart&lt;br /&gt;
&lt;br /&gt;
#Wait 30 seconds&lt;br /&gt;
echo &amp;quot;Wait 30 seconds to ensure dashboard has created the empty indices with new mapping&amp;quot;&lt;br /&gt;
sleep 30&lt;br /&gt;
echo -e &amp;quot;\n&amp;quot;&lt;br /&gt;
&lt;br /&gt;
#When index has no docs the reindex doesn't create the new index (typically transferfiles index)&lt;br /&gt;
#There's a check to ensure the new index has been create before reindexing. &lt;br /&gt;
#Reindex fron *_new indices:&lt;br /&gt;
for index in $index_list;do&lt;br /&gt;
  if echo &amp;quot;$indices_output&amp;quot; | grep ${index}_new &amp;gt;/dev/null; then&lt;br /&gt;
    echo &amp;quot;Indexing ${index} using ${index}_new ...&amp;quot;&lt;br /&gt;
    curl -s -X POST \&lt;br /&gt;
      ${es_url}/_reindex \&lt;br /&gt;
      -H 'Content-Type: application/json' \&lt;br /&gt;
      -d '{&lt;br /&gt;
      &amp;quot;source&amp;quot;: {&lt;br /&gt;
        &amp;quot;index&amp;quot;: &amp;quot;'&amp;quot;${index}_new&amp;quot;'&amp;quot;&lt;br /&gt;
      },&lt;br /&gt;
      &amp;quot;dest&amp;quot;: {&lt;br /&gt;
        &amp;quot;index&amp;quot;: &amp;quot;'&amp;quot;${index}&amp;quot;'&amp;quot;&lt;br /&gt;
      }&lt;br /&gt;
    }' &amp;gt; /dev/null&lt;br /&gt;
  fi&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
echo -e &amp;quot;\n&amp;quot;&lt;br /&gt;
&lt;br /&gt;
#Delete tmp indices&lt;br /&gt;
for index in $index_list;do&lt;br /&gt;
  if echo &amp;quot;$indices_output&amp;quot; | grep ${index}_new &amp;gt;/dev/null; then&lt;br /&gt;
     echo &amp;quot;Deleting ${index}_new...&amp;quot;&lt;br /&gt;
     curl -s -X DELETE ${es_url}/${index}_new &amp;gt; /dev/null&lt;br /&gt;
  fi&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
echo -e &amp;quot;\n\nReindexing done:\n&amp;quot;&lt;br /&gt;
curl -s -X GET &amp;quot;${es_url}/_cat/indices/%2A?v=&amp;amp;s=index:desc&amp;quot;&lt;br /&gt;
echo -e &amp;quot;\n&amp;quot;&lt;br /&gt;
&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For our example it takes 11 minutes, and this is the output:&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;&lt;br /&gt;
root@archivematica-test-server:~# time ./script_reindex_new_map.sh &lt;br /&gt;
&lt;br /&gt;
Index list before reindexing:&lt;br /&gt;
&lt;br /&gt;
health status index         uuid                   pri rep docs.count docs.deleted store.size pri.store.size&lt;br /&gt;
yellow open   transfers     lYqkYjwZRy2XG8CP_3S3PQ   5   1          3            0     11.6kb         11.6kb&lt;br /&gt;
yellow open   transferfiles K5gnDZyOQz2JdIeZ6adJsQ   5   1          0            0      1.2kb          1.2kb&lt;br /&gt;
yellow open   aips          yAyK_koXThaZcWsBYfzN7w   5   1         17            0    101.4mb        101.4mb&lt;br /&gt;
yellow open   aipfiles      TVrrX8jkRhWWxGfvK_M6zg   5   1      12905            0      2.6gb          2.6gb&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Reindex aips in aips_new...&lt;br /&gt;
Reindex aipfiles in aipfiles_new...&lt;br /&gt;
Reindex transfers in transfers_new...&lt;br /&gt;
Reindex transferfiles in transferfiles_new...&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Index list after tmp indices creation&lt;br /&gt;
&lt;br /&gt;
health status index         uuid                   pri rep docs.count docs.deleted store.size pri.store.size&lt;br /&gt;
yellow open   transfers_new gdFevH8yRdiNTdrPcfo8Lg   5   1          0            0       460b           460b&lt;br /&gt;
yellow open   transfers     lYqkYjwZRy2XG8CP_3S3PQ   5   1          3            0     11.6kb         11.6kb&lt;br /&gt;
yellow open   transferfiles K5gnDZyOQz2JdIeZ6adJsQ   5   1          0            0      1.2kb          1.2kb&lt;br /&gt;
yellow open   aips_new      uJ-ehaYLTfe_1lOSErfu3Q   5   1         17            0     96.8mb         96.8mb&lt;br /&gt;
yellow open   aips          yAyK_koXThaZcWsBYfzN7w   5   1         17            0    101.4mb        101.4mb&lt;br /&gt;
yellow open   aipfiles_new  00Xxu7v2QvWsq92gM247xQ   5   1      12905            0      3.1gb          3.1gb&lt;br /&gt;
yellow open   aipfiles      TVrrX8jkRhWWxGfvK_M6zg   5   1      12905            0      2.6gb          2.6gb&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Deleting aips...&lt;br /&gt;
Deleting aipfiles...&lt;br /&gt;
Deleting transfers...&lt;br /&gt;
Deleting transferfiles...&lt;br /&gt;
&lt;br /&gt;
Restarting archivematica-dashboard&lt;br /&gt;
Wait 30 seconds to ensure dashboard has created the empty indices with new mapping&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Indexing aips using aips_new ...&lt;br /&gt;
Indexing aipfiles using aipfiles_new ...&lt;br /&gt;
Indexing transfers using transfers_new ...&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Deleting aips_new...&lt;br /&gt;
Deleting aipfiles_new...&lt;br /&gt;
Deleting transfers_new...&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Reindexing done:&lt;br /&gt;
&lt;br /&gt;
health status index         uuid                   pri rep docs.count docs.deleted store.size pri.store.size&lt;br /&gt;
yellow open   transfers     FC7aSVPmSmmCc_LTv1AQRA   5   1          3            0      1.2kb          1.2kb&lt;br /&gt;
yellow open   transferfiles 5JMAft3FQwmosZQFi7eJNw   5   1          0            0      1.2kb          1.2kb&lt;br /&gt;
yellow open   aips          EtwXG3-4SO2Px-4QMRufXA   5   1         17            0    102.1mb        102.1mb&lt;br /&gt;
yellow open   aipfiles      -PFuzslgTeWJ4CWny8VZoA   5   1      12905            0        3gb            3gb&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
real	10m47.114s&lt;br /&gt;
user	0m0.068s&lt;br /&gt;
sys	0m0.032s&lt;br /&gt;
&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The script uses the elasticsearch API and makes the following actions:&lt;br /&gt;
&lt;br /&gt;
* Reindex the ''transfers'', ''transferfiles'', ''aips'' and ''aipfiles'' indices in new temporary indices&lt;br /&gt;
* Delete original indices&lt;br /&gt;
* Restart ''archivematica-dashboard'' service to create empty indices with new mappings&lt;br /&gt;
* Reindex from temporary indices&lt;br /&gt;
* Delete temporary indices&lt;br /&gt;
&lt;br /&gt;
= Restore Elasticsearch heap size when needed=&lt;br /&gt;
&lt;br /&gt;
* Edit ''/etc/default/elasticsearch'' or ''/etc/sysconfig/elasticsearch'' when needed.&lt;br /&gt;
* Change ''ES_JAVA_OPTS'' when needed.&lt;br /&gt;
* Restart Elasticsearch service when needed (''sudo service elasticsearch restart'')&lt;/div&gt;</summary>
		<author><name>Mamedin</name></author>
	</entry>
	<entry>
		<id>https://wiki.archivematica.org/index.php?title=Update_ElasticSearch&amp;diff=12908</id>
		<title>Update ElasticSearch</title>
		<link rel="alternate" type="text/html" href="https://wiki.archivematica.org/index.php?title=Update_ElasticSearch&amp;diff=12908"/>
		<updated>2019-02-27T17:20:04Z</updated>

		<summary type="html">&lt;p&gt;Mamedin: /* ElasticSearch update */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= ElasticSearch update =&lt;br /&gt;
&lt;br /&gt;
1. Backup elasticsearch data directory &lt;br /&gt;
&lt;br /&gt;
  sudo service elasticsearch stop&lt;br /&gt;
  sudo tar cfz var_lib_elasticsearch_$(date +%y%m%d).tgz  /var/lib/elasticsearch&lt;br /&gt;
  sudo service elasticsearch start&lt;br /&gt;
&lt;br /&gt;
2. Check that ES is up and running, and note the results:&lt;br /&gt;
&lt;br /&gt;
  curl -X GET &amp;quot;localhost:9200/_cat/indices?v&amp;quot;&lt;br /&gt;
  health status index     pri rep docs.count docs.deleted store.size pri.store.size &lt;br /&gt;
  yellow open   aips        5   1      24816            1    175.4mb        175.4mb &lt;br /&gt;
  yellow open   transfers   5   1          0            0       720b           720b &lt;br /&gt;
&lt;br /&gt;
Check also if there are any configured snapshot:&lt;br /&gt;
&lt;br /&gt;
  curl -XGET &amp;quot;localhost:9200/_snapshot/_all?pretty&amp;quot;&lt;br /&gt;
&lt;br /&gt;
3. Remove Snapshots&lt;br /&gt;
&lt;br /&gt;
If there are any snapshot (step 1), please remove it:&lt;br /&gt;
&lt;br /&gt;
  curl -XDELETE &amp;quot;localhost:9200/_snapshot/backup-repo?pretty&amp;quot;&lt;br /&gt;
&lt;br /&gt;
4. Stop elasticsearch service&lt;br /&gt;
&lt;br /&gt;
  sudo service elasticsearch stop&lt;br /&gt;
&lt;br /&gt;
5. Check wich elasticsearch version is installed&lt;br /&gt;
&lt;br /&gt;
  Redhat/Centos: rpm -q elasticsearch&lt;br /&gt;
  Ubuntu: dpkg -l elasticsearch&lt;br /&gt;
&lt;br /&gt;
6. Download a temporary copy of elasticsearch (same version than intalled)&lt;br /&gt;
&lt;br /&gt;
  wget https://download.elastic.co/elasticsearch/elasticsearch/elasticsearch-1.7.5.tar.gz&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
7. Uncompress the downloaded tar.gz and go into it&lt;br /&gt;
&lt;br /&gt;
  tar zxvf elasticsearch-1.7.5.tar.gz&lt;br /&gt;
  cd elasticsearch-1.7.5&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
8. Copy data from system wide installed elasticsearch, ot the temporary copy&lt;br /&gt;
&lt;br /&gt;
  sudo cp /var/lib/elasticsearch data -rf&lt;br /&gt;
&lt;br /&gt;
9. Adjust file permissions&lt;br /&gt;
&lt;br /&gt;
  sudo chown &amp;lt;your user&amp;gt;:&amp;lt;your group&amp;gt; data -R&lt;br /&gt;
&lt;br /&gt;
10. Launch the temporary elasticsearch instance&lt;br /&gt;
&lt;br /&gt;
  ES_JAVA_OPTS=&amp;quot;-Xms2g -Xmx2g&amp;quot; ./bin/elasticsearch -d -p elastic-tmp.pid -Des.http.port=9500&lt;br /&gt;
&lt;br /&gt;
11. Verify that the indexes were properly copied. Use the port specified in the previous command:&lt;br /&gt;
&lt;br /&gt;
  curl -X GET &amp;quot;localhost:9500/_cat/indices?v&amp;quot;&lt;br /&gt;
&lt;br /&gt;
12. Remove elasticsearch 1.7.5 and it's files&lt;br /&gt;
&lt;br /&gt;
  Redhat: sudo yum remove elasticsearch&lt;br /&gt;
  Ubuntu: sudo apt-get remove --purge elasticsearch&lt;br /&gt;
  sudo mv /var/lib/elasticsearch /var/lib/elasticsearch-1.7.5&lt;br /&gt;
  sudo mv /etc/elasticsearch /etc/elasticsearch-1.7.5&lt;br /&gt;
&lt;br /&gt;
13. Upgrade archivematica and install elasticsearch 6&lt;br /&gt;
&lt;br /&gt;
  ansible-playbook -i hosts singlenode.yml --tags=elasticsearch,archivematica-src&lt;br /&gt;
&lt;br /&gt;
14. Configure ElasticSearch 6 to handle reindex from the temporary es &lt;br /&gt;
&lt;br /&gt;
  echo 'reindex.remote.whitelist: localhost:9500' | sudo tee -a /etc/elasticsearch/elasticsearch.yml&lt;br /&gt;
  sudo service elasticsearch restart&lt;br /&gt;
&lt;br /&gt;
15. Migrate the indexes&lt;br /&gt;
&lt;br /&gt;
  sudo -u archivematica bash -c &amp;quot; \&lt;br /&gt;
  set -a -e -x&lt;br /&gt;
  source /etc/default/archivematica-dashboard || \&lt;br /&gt;
  source /etc/sysconfig/archivematica-dashboard \&lt;br /&gt;
        || (echo 'Environment file not found'; exit 1)&lt;br /&gt;
  cd /usr/share/archivematica/dashboard&lt;br /&gt;
  /usr/share/archivematica/virtualenvs/archivematica-dashboard/bin/python manage.py reindex_from_remote_cluster -t 60 -s 10 http://localhost:9500&lt;br /&gt;
  &amp;quot;;&lt;br /&gt;
&lt;br /&gt;
The command should finish with&lt;br /&gt;
  &lt;br /&gt;
  All reindex requests ended successfully!&lt;br /&gt;
&lt;br /&gt;
Else, you might need to tweak the timeout (-t) and size (-s) parameters.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
16. Verify that the new indexes were created and populated:&lt;br /&gt;
&lt;br /&gt;
  curl -X GET &amp;quot;localhost:9200/_cat/indices?v&amp;quot; &lt;br /&gt;
  health status index         uuid                   pri rep docs.count docs.deleted store.size pri.store.size&lt;br /&gt;
  yellow open   transferfiles jlu2d2yZQpWwpKKT1ZzMAA   5   1          0            0      1.1kb          1.1kb&lt;br /&gt;
  yellow open   aips          VAvONAByRBuVcWBYhlhUmw   5   1        116            0     66.9mb         66.9mb&lt;br /&gt;
  yellow open   transfers     OhfLVBzuRqCNUYRCSSTidg   5   1          0            0      1.1kb          1.1kb&lt;br /&gt;
  yellow open   aipfiles      clX1gcqnT9CTdwTm8jeatw   5   1      24700            0     70.6mb         70.6mb&lt;br /&gt;
&lt;br /&gt;
You should have 4 indexes now, and the sum of the aips and aipfiles docs.count column should be equal to the doc.count for the aip index in ElasticSearch 1.7.5. The same happens with the transfers/transferfiles indexes.&lt;br /&gt;
&lt;br /&gt;
17. Stop the temporary elasticsearch service&lt;br /&gt;
&lt;br /&gt;
  kill $(cat ~/elasticsearch-1.7.5/elastic-tmp.pid)&lt;br /&gt;
&lt;br /&gt;
18. Restart all archivematica services&lt;br /&gt;
  &lt;br /&gt;
  service archivematica-mcp-server restart&lt;br /&gt;
  service archivematica-mcp-client restart&lt;br /&gt;
  service archivematica-dashboard restart&lt;br /&gt;
  service archivematica-storage-service restart&lt;/div&gt;</summary>
		<author><name>Mamedin</name></author>
	</entry>
	<entry>
		<id>https://wiki.archivematica.org/index.php?title=Update_ElasticSearch&amp;diff=12907</id>
		<title>Update ElasticSearch</title>
		<link rel="alternate" type="text/html" href="https://wiki.archivematica.org/index.php?title=Update_ElasticSearch&amp;diff=12907"/>
		<updated>2019-02-27T17:16:15Z</updated>

		<summary type="html">&lt;p&gt;Mamedin: /* ElasticSearch update */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= ElasticSearch update =&lt;br /&gt;
&lt;br /&gt;
1. Backup elasticsearch data directory &lt;br /&gt;
&lt;br /&gt;
  sudo service elasticsearch stop&lt;br /&gt;
  sudo tar cfz var_lib_elasticsearch_$(date).tgz  /var/lib/elasticsearch&lt;br /&gt;
  sudo service elasticsearch start&lt;br /&gt;
&lt;br /&gt;
2. Check that ES is up and running, and note the results:&lt;br /&gt;
&lt;br /&gt;
  curl -X GET &amp;quot;localhost:9200/_cat/indices?v&amp;quot;&lt;br /&gt;
  health status index     pri rep docs.count docs.deleted store.size pri.store.size &lt;br /&gt;
  yellow open   aips        5   1      24816            1    175.4mb        175.4mb &lt;br /&gt;
  yellow open   transfers   5   1          0            0       720b           720b &lt;br /&gt;
&lt;br /&gt;
Check also if there are any configured snapshot:&lt;br /&gt;
&lt;br /&gt;
  curl -XGET &amp;quot;localhost:9200/_snapshot/_all?pretty&amp;quot;&lt;br /&gt;
&lt;br /&gt;
3. Remove Snapshots&lt;br /&gt;
&lt;br /&gt;
If there are any snapshot (step 1), please remove it:&lt;br /&gt;
&lt;br /&gt;
  curl -XDELETE &amp;quot;localhost:9200/_snapshot/backup-repo?pretty&amp;quot;&lt;br /&gt;
&lt;br /&gt;
4. Stop elasticsearch service&lt;br /&gt;
&lt;br /&gt;
  sudo service elasticsearch stop&lt;br /&gt;
&lt;br /&gt;
5. Check wich elasticsearch version is installed&lt;br /&gt;
&lt;br /&gt;
  Redhat/Centos: rpm -q elasticsearch&lt;br /&gt;
  Ubuntu: dpkg -l elasticsearch&lt;br /&gt;
&lt;br /&gt;
6. Download a temporary copy of elasticsearch (same version than intalled)&lt;br /&gt;
&lt;br /&gt;
  wget https://download.elastic.co/elasticsearch/elasticsearch/elasticsearch-1.7.5.tar.gz&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
7. Uncompress the downloaded tar.gz and go into it&lt;br /&gt;
&lt;br /&gt;
  tar zxvf elasticsearch-1.7.5.tar.gz&lt;br /&gt;
  cd elasticsearch-1.7.5&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
8. Copy data from system wide installed elasticsearch, ot the temporary copy&lt;br /&gt;
&lt;br /&gt;
  sudo cp /var/lib/elasticsearch data -rf&lt;br /&gt;
&lt;br /&gt;
9. Adjust file permissions&lt;br /&gt;
&lt;br /&gt;
  sudo chown &amp;lt;your user&amp;gt;:&amp;lt;your group&amp;gt; data -R&lt;br /&gt;
&lt;br /&gt;
10. Launch the temporary elasticsearch instance&lt;br /&gt;
&lt;br /&gt;
  ES_JAVA_OPTS=&amp;quot;-Xms2g -Xmx2g&amp;quot; ./bin/elasticsearch -d -p elastic-tmp.pid -Des.http.port=9500&lt;br /&gt;
&lt;br /&gt;
11. Verify that the indexes were properly copied. Use the port specified in the previous command:&lt;br /&gt;
&lt;br /&gt;
  curl -X GET &amp;quot;localhost:9500/_cat/indices?v&amp;quot;&lt;br /&gt;
&lt;br /&gt;
12. Remove elasticsearch 1.7.5 and it's files&lt;br /&gt;
&lt;br /&gt;
  Redhat: sudo yum remove elasticsearch&lt;br /&gt;
  Ubuntu: sudo apt-get remove --purge elasticsearch&lt;br /&gt;
  sudo mv /var/lib/elasticsearch /var/lib/elasticsearch-1.7.5&lt;br /&gt;
  sudo mv /etc/elasticsearch /etc/elasticsearch-1.7.5&lt;br /&gt;
&lt;br /&gt;
13. Upgrade archivematica and install elasticsearch 6&lt;br /&gt;
&lt;br /&gt;
  ansible-playbook -i hosts singlenode.yml --tags=elasticsearch,archivematica-src&lt;br /&gt;
&lt;br /&gt;
14. Configure ElasticSearch 6 to handle reindex from the temporary es &lt;br /&gt;
&lt;br /&gt;
  echo 'reindex.remote.whitelist: localhost:9500' | sudo tee -a /etc/elasticsearch/elasticsearch.yml&lt;br /&gt;
  sudo service elasticsearch restart&lt;br /&gt;
&lt;br /&gt;
15. Migrate the indexes&lt;br /&gt;
&lt;br /&gt;
  sudo -u archivematica bash -c &amp;quot; \&lt;br /&gt;
  set -a -e -x&lt;br /&gt;
  source /etc/default/archivematica-dashboard || \&lt;br /&gt;
  source /etc/sysconfig/archivematica-dashboard \&lt;br /&gt;
        || (echo 'Environment file not found'; exit 1)&lt;br /&gt;
  cd /usr/share/archivematica/dashboard&lt;br /&gt;
  /usr/share/archivematica/virtualenvs/archivematica-dashboard/bin/python manage.py reindex_from_remote_cluster -t 60 -s 10 http://localhost:9500&lt;br /&gt;
  &amp;quot;;&lt;br /&gt;
&lt;br /&gt;
The command should finish with&lt;br /&gt;
  &lt;br /&gt;
  All reindex requests ended successfully!&lt;br /&gt;
&lt;br /&gt;
Else, you might need to tweak the timeout (-t) and size (-s) parameters.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
16. Verify that the new indexes were created and populated:&lt;br /&gt;
&lt;br /&gt;
  curl -X GET &amp;quot;localhost:9200/_cat/indices?v&amp;quot; &lt;br /&gt;
  health status index         uuid                   pri rep docs.count docs.deleted store.size pri.store.size&lt;br /&gt;
  yellow open   transferfiles jlu2d2yZQpWwpKKT1ZzMAA   5   1          0            0      1.1kb          1.1kb&lt;br /&gt;
  yellow open   aips          VAvONAByRBuVcWBYhlhUmw   5   1        116            0     66.9mb         66.9mb&lt;br /&gt;
  yellow open   transfers     OhfLVBzuRqCNUYRCSSTidg   5   1          0            0      1.1kb          1.1kb&lt;br /&gt;
  yellow open   aipfiles      clX1gcqnT9CTdwTm8jeatw   5   1      24700            0     70.6mb         70.6mb&lt;br /&gt;
&lt;br /&gt;
You should have 4 indexes now, and the sum of the aips and aipfiles docs.count column should be equal to the doc.count for the aip index in ElasticSearch 1.7.5. The same happens with the transfers/transferfiles indexes.&lt;br /&gt;
&lt;br /&gt;
17. Stop the temporary elasticsearch service&lt;br /&gt;
&lt;br /&gt;
  kill $(cat ~/elasticsearch-1.7.5/elastic-tmp.pid)&lt;br /&gt;
&lt;br /&gt;
18. Restart all archivematica services&lt;br /&gt;
  &lt;br /&gt;
  service archivematica-mcp-server restart&lt;br /&gt;
  service archivematica-mcp-client restart&lt;br /&gt;
  service archivematica-dashboard restart&lt;br /&gt;
  service archivematica-storage-service restart&lt;/div&gt;</summary>
		<author><name>Mamedin</name></author>
	</entry>
</feed>