Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

In all code blocks below Kibana is expected to be used for sending requests to Elasticsearch.

No need to preserve existing data

In that case simply delete existing index after stopping Aspire. When you start Aspire 5.2 version the index will be automatically created with the existing new mapping.

Code Block
DELETE aspire-identitycache

Convert existing data

  1. Stop Aspire
  2. Create new index aspire-identitycache_new with new 5.2 mapping
  3. Run reindex script to convert data from the old index aspire-identitycache to the new one aspire-identitycache_new
  4. Delete old index aspire-identitycache
  5. Create alias aspire-identitycache and assign it to the new index  aspire-identitycache_new
  6. Start Aspire 5.2

Create new index aspire-identitycache_new with new 5.2 mapping

Note
titleWarning

If you want to preserve settings related to the number of shards or replicas, you must also include the 'settings' part.

Code Block
PUT aspire-identitycache_new
    "mappings": {
      "properties": {
        "mappingsidentity": {
          "properties": {
            "identity.seedId": {
              "type": "keyword"
            },
            "identity.timestamp": {
              "type": "keyword"
        }
    }
  },
       "dynamic_templates": [ }
        {}
      },
      "alldynamic_as_keywordtemplates": {[
        {
          "matchall_mappingas_typekeyword": "*",{
            "path_match": "identity.attributes.*",
            "mapping": {
              "type": "keyword"
            }
          }
        },
        {
          "date_to_string": {
            "match_mapping_type": "date",
            "mapping": {
              "type": "text"
            }
          }
        },
        {
          "boolean_to_string": {
            "match_mapping_type": "boolean",
            "mapping": {
              "type": "text"
            }
          }
        },
        {
          "long_to_string": {
            "match_mapping_type": "long",
            "mapping": {
              "type": "text"
            }
          }
        },
        {
          "double_to_string": {
            "match_mapping_type": "double",
            "mapping": {
              "type": "text"
            }
          }
        },
        {
          "binary_to_string": {
            "match_mapping_type": "binary",
            "mapping": {
              "type": "text"
            }
          }
        }
      ]
    }
  }

Run reindex script

Code Block
POST _reindex
{
  "source": {
    "index": "aspire-identitycache"
  },
  "dest": {
    "index": "aspire-identitycache_new"
  },
  "script": {
    "lang": "painless",
    "source": """
    String seedHash = null;
    Map seedHashObject = null;
    
    def identity = ctx._source.identity;
    if (identity != null) {
      for (def entry : identity.entrySet()) {
        def val = entry.getValue();
        if (val instanceof Map && val.containsKey('attributes')) {
          seedHash = entry.getKey();
          seedHashObject = val;
        }
      }
    }
    
    if(seedHash != null){
          Map attributes =  seedHashObject.get('attributes');
      identity.remove(seedHash);
      identity.put('attributes', attributes);
    }

      """
  }
}

Delete old index

Code Block
DELETE aspire-identitycache

Create new alias

Code Block
POST _aliases
{
  "actions": [
    {
      "add": {
        "index": "aspire-identitycache_new",
        "alias": "aspire-identitycache"
      }
    }
  ]
}

...