...
Code Block |
---|
PUT aspire-identitycache_new "mappings": { "mappingsproperties": { "identity": { "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" } } } ] } } |
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); } """ } } |
...