Home > database >  Renaming a index in Elasticsearch so it falls into a desired index pattern
Renaming a index in Elasticsearch so it falls into a desired index pattern

Time:01-07

My goal is to rename an index named foo, so it falls into an index pattern named bar, which includes indices named bar*. I do not want to reindex the whole index so its rather large, for it would take up massive amounts of resources.

I see Elasticsearch rename index , as a possible solution, but if I add an alias called "bar-0001" to the index named "foo", would "foo" fall into the the "bar*" index pattern?

Or could I add the index named foo to the index pattern bar?

For reference, the index is about 5GB with ~2.5 million docs.

Thanks

CodePudding user response:

I believe alias resolve your problem.

Example

Create three indices: bar_01, bar_02, foo_01

PUT bar_01

PUT bar_02

PUT foo_01

Add alias bar_alais to indice foo_01

POST _aliases
{
  "actions": [
    {
      "add": {
        "index": "foo_01",
        "alias": "bar_alias"
      }
    }
  ]
}

Get all indice start with bar

GET bar*

Return indices bar_01, 02 and foo_01

{
  "bar_01": {
    "aliases": {},
  ...
    }
  },
  "bar_02": {
    "aliases": {},
  ...
    }
  },
  "foo_01": {
    "aliases": {
      "bar_alias": {}
    },
....
  }
}
  • Related