0

Let's say I got the alias car-alias pointing to car-index-1. I now want car-alias to point to car-index-2.

I therefore perform the following POST request to the Aliases API:

{
  "actions": [
    {
      "remove": {
        "index": "car-index-1",
        "alias": "car-alias"
      }
    },
    {
      "add": {
        "index": "car-index-2",
        "alias": "car-alias"
      }
    }
  ]
}

I receive the following response:

{
   "acknowledged": true
}

Can I now immediately index data into the car-alias and it ends up in the car-index-2?

Or does the "acknowledged": true response not guarantee that write operations point to the right index immediately?

Harold L. Brown
  • 8,423
  • 11
  • 57
  • 109

2 Answers2

1

Yes, the alias is changed atomically and will point to car-index-2 immediately when the call returns.

As stated in the documentation "...during the swap, the alias has no downtime and never points to both streams at the same time."

Val
  • 207,596
  • 13
  • 358
  • 360
  • So the `acknowledged` flag does not mean that Elasticsearch just acknowledged the operation, but still maybe has some processing to do until is is completed? – Harold L. Brown Jan 17 '22 at 12:35
  • 1
    No, it means it's safe and the writes will go to the new index. – Val Jan 17 '22 at 12:35
1

In addition to @Val's answer:

Since in your case, the alias only points to one index, the "next" index is automatically set as the write index.

From the docs regarding the is_write_index option of the add action:

is_write_index (Optional, Boolean) If true, sets the write index or data stream for the alias.

If an alias points to multiple indices or data streams and is_write_index isn’t set, the alias rejects write requests. If an index alias points to one index and is_write_index isn’t set, the index automatically acts as the write index. [...]

Only the add action supports this parameter.

apt-get_install_skill
  • 2,818
  • 10
  • 27
  • 1
    Note that this is only useful if the alias points to more than one indexes, the one to which the write requests should go, must be configured with `is_write_index: true`, but it doesn't seem to be the case here. – Val Jan 17 '22 at 12:34