-
Notifications
You must be signed in to change notification settings - Fork 0
Managing ElasticSearch indices
Nicolas Steenlant edited this page Nov 30, 2022
·
2 revisions
There are 2 indices per object type environment:
Publication:
biblio_backoffice_prod_publication_1
biblio_backoffice_prod_publication_2
biblio_backoffice_dev_publication_1
biblio_backoffice_dev_publication_2
These are referenced via an alias: biblio_backoffice_<env>_publication
Dataset:
biblio_backoffice_prod_dataset_1
biblio_backoffice_prod_dataset_2
biblio_backoffice_dev_dataset_1
biblio_backoffice_dev_dataset_2
These are referenced via an alias: biblio_backoffice_<env>_dataset
This is useful when you've made a change to the index mapping schema.
e.g. the alias points to index 1. We want to update the schema of index 2, then point the alias to index 2 and re-index all the data on index 2. These are the steps you'd take:
Step 0: Source the environment variables for the correct environment
source biblio-backoffice-prod-env.sh
Step 1: Update the mapping on index 2
curl -XPUT -H "Content-Type: application/json" --data @publication-mapping.json http://es-server:9200/biblio_backoffice_prod_publication_2
Step 2: Copy the data from index 1 to index 2
curl -XPOST -H "Content-Type: application/json" --data @copy_index_publication_prod_1_2.json http://es-server:9200/_reindex
copy_index_publication_prod_1_2.json:
{
"source": {
"index": "biblio_backoffice_prod_publication_1"
},
"dest": {
"index": "biblio_backoffice_prod_publication_2"
}
}
Step 3: Switch the alias to index 2 and re-index the data
curl -XPOST -H "Content-Type: application/json" --data @alias_prod_publication_2.json http://es-server:9200/_aliases; ./biblio-backoffice.linux.amd64 index publication all
alias_prod_publication_2.json:
{
"actions": [
{
"remove": {
"index": "biblio_backoffice_prod_publication_1",
"alias": "biblio_backoffice_prod_publication"
}
},
{
"add": {
"index": "biblio_backoffice_prod_publication_2",
"alias": "biblio_backoffice_prod_publication"
}
}
]
}