2014-10-07 11:09:50 -04:00
|
|
|
[[indices-upgrade]]
|
|
|
|
== Upgrade
|
|
|
|
|
2015-06-05 11:50:10 -04:00
|
|
|
The upgrade API allows to upgrade one or more indices to the latest Lucene
|
|
|
|
format through an API. The upgrade process converts any segments written with
|
|
|
|
older formats.
|
|
|
|
|
2016-03-31 08:34:31 -04:00
|
|
|
[IMPORTANT]
|
|
|
|
===================================================
|
2015-06-05 11:50:10 -04:00
|
|
|
|
2016-03-31 08:34:31 -04:00
|
|
|
**The upgrade API in its current form will not help you to migrate indices
|
|
|
|
created in Elasticsearch 1.x to 5.x.**
|
2015-06-05 11:50:10 -04:00
|
|
|
|
2016-03-31 08:34:31 -04:00
|
|
|
The upgrade API rewrites an index in the latest Lucene format, but it still
|
|
|
|
retains the original data structures that were used when the index was first
|
|
|
|
created. For instance:
|
2015-06-05 11:50:10 -04:00
|
|
|
|
2016-03-31 08:34:31 -04:00
|
|
|
* Doc-values on numeric fields used to use BinaryDocValues, but now use dedicated NumericDocValues.
|
|
|
|
* The parent-child feature has been completely rewritten to use a new data structure.
|
|
|
|
* Geo-point fields now require doc values and the Lucene index where, previously, they relied on in-memory calculations.
|
2015-06-05 11:50:10 -04:00
|
|
|
|
2016-03-31 08:34:31 -04:00
|
|
|
**Migrating 1.x indices to 5.x**
|
2015-06-05 11:50:10 -04:00
|
|
|
|
2016-03-31 08:34:31 -04:00
|
|
|
The only way to prepare an index created in 1.x for use in 5.x is to **reindex
|
|
|
|
your data** in a cluster running Elasticsearch 2.3.x, which you can do with
|
|
|
|
the new <<docs-reindex,reindex API>>.
|
2015-06-05 11:50:10 -04:00
|
|
|
|
2016-03-31 08:34:31 -04:00
|
|
|
The steps to do this are as follows:
|
2015-06-05 11:50:10 -04:00
|
|
|
|
2016-03-31 08:34:31 -04:00
|
|
|
1. Create a new index (e.g. `new_index`) with the correct settings and
|
|
|
|
mappings. These can be retrieved from the old index with the
|
|
|
|
<<indices-get-index,get-index>> API.
|
2015-06-05 11:50:10 -04:00
|
|
|
|
2016-03-31 08:34:31 -04:00
|
|
|
2. Reindex from `old_index` to `new_index` with the
|
|
|
|
<<docs-reindex,reindex API>>.
|
2015-06-05 11:50:10 -04:00
|
|
|
|
2016-03-31 08:34:31 -04:00
|
|
|
3. Retrieve a list of any aliases associated with the `old_index` using the
|
|
|
|
<<alias-retrieving,get-alias API>>.
|
2015-06-05 11:50:10 -04:00
|
|
|
|
2016-03-31 08:34:31 -04:00
|
|
|
4. Delete the `old_index` using the <<indices-delete-index,delete index API>>.
|
2015-06-05 11:50:10 -04:00
|
|
|
|
2016-03-31 08:34:31 -04:00
|
|
|
5. Add an alias called `old_index` to the `new_index` along with any aliases
|
|
|
|
returned in step 3, using the <<indices-aliases,update aliases API>>.
|
2015-06-05 11:50:10 -04:00
|
|
|
|
2016-03-31 08:34:31 -04:00
|
|
|
In the future, we plan to change the upgrade API to perform a reindex-in-
|
|
|
|
place. In other words, it would reindex data from `old_index` to `.old_index`
|
|
|
|
then atomically delete `old_index` and rename `.old_index` to `old_index`.
|
|
|
|
|
|
|
|
===================================================
|
2015-06-05 11:50:10 -04:00
|
|
|
|
2014-10-07 11:09:50 -04:00
|
|
|
|
2014-10-11 10:22:24 -04:00
|
|
|
[float]
|
2014-10-07 11:09:50 -04:00
|
|
|
=== Start an upgrade
|
2014-10-11 10:22:24 -04:00
|
|
|
|
|
|
|
[source,sh]
|
2014-10-07 11:09:50 -04:00
|
|
|
--------------------------------------------------
|
|
|
|
$ curl -XPOST 'http://localhost:9200/twitter/_upgrade'
|
|
|
|
--------------------------------------------------
|
|
|
|
|
2014-10-11 10:22:24 -04:00
|
|
|
NOTE: Upgrading is an I/O intensive operation, and is limited to processing a
|
|
|
|
single shard per node at a time. It also is not allowed to run at the same
|
2015-09-17 16:36:25 -04:00
|
|
|
time as an optimize/force-merge.
|
2014-10-07 11:09:50 -04:00
|
|
|
|
2015-02-10 17:52:19 -05:00
|
|
|
This call will block until the upgrade is complete. If the http connection
|
|
|
|
is lost, the request will continue in the background, and
|
|
|
|
any new requests will block until the previous upgrade is complete.
|
2014-10-07 11:09:50 -04:00
|
|
|
|
2015-04-16 04:54:00 -04:00
|
|
|
[float]
|
|
|
|
[[upgrade-parameters]]
|
|
|
|
==== Request Parameters
|
|
|
|
|
|
|
|
The `upgrade` API accepts the following request parameters:
|
|
|
|
|
|
|
|
[horizontal]
|
|
|
|
`only_ancient_segments`:: If true, only very old segments (from a
|
|
|
|
previous Lucene major release) will be upgraded. While this will do
|
|
|
|
the minimal work to ensure the next major release of Elasticsearch can
|
|
|
|
read the segments, it's dangerous because it can leave other very old
|
|
|
|
segments in sub-optimal formats. Defaults to `false`.
|
|
|
|
|
2014-10-11 10:22:24 -04:00
|
|
|
[float]
|
2014-10-07 11:09:50 -04:00
|
|
|
=== Check upgrade status
|
2014-10-11 10:22:24 -04:00
|
|
|
|
2014-10-07 11:09:50 -04:00
|
|
|
Use a `GET` request to monitor how much of an index is upgraded. This
|
2015-04-16 04:54:00 -04:00
|
|
|
can also be used prior to starting an upgrade to identify which
|
|
|
|
indices you want to upgrade at the same time.
|
|
|
|
|
|
|
|
The `ancient` byte values that are returned indicate total bytes of
|
|
|
|
segments whose version is extremely old (Lucene major version is
|
|
|
|
different from the current version), showing how much upgrading is
|
|
|
|
necessary when you run with `only_ancient_segments=true`.
|
2014-10-11 10:22:24 -04:00
|
|
|
|
|
|
|
[source,sh]
|
2014-10-07 11:09:50 -04:00
|
|
|
--------------------------------------------------
|
2015-01-16 07:55:22 -05:00
|
|
|
curl 'http://localhost:9200/twitter/_upgrade?pretty&human'
|
2014-10-07 11:09:50 -04:00
|
|
|
--------------------------------------------------
|
|
|
|
|
|
|
|
[source,js]
|
|
|
|
--------------------------------------------------
|
|
|
|
{
|
2015-05-24 18:22:06 -04:00
|
|
|
"size": "21gb",
|
|
|
|
"size_in_bytes": "21000000000",
|
|
|
|
"size_to_upgrade": "10gb",
|
|
|
|
"size_to_upgrade_in_bytes": "10000000000"
|
|
|
|
"size_to_upgrade_ancient": "1gb",
|
|
|
|
"size_to_upgrade_ancient_in_bytes": "1000000000"
|
|
|
|
"indices": {
|
|
|
|
"twitter": {
|
2014-10-07 11:09:50 -04:00
|
|
|
"size": "21gb",
|
|
|
|
"size_in_bytes": "21000000000",
|
|
|
|
"size_to_upgrade": "10gb",
|
|
|
|
"size_to_upgrade_in_bytes": "10000000000"
|
2015-04-16 04:54:00 -04:00
|
|
|
"size_to_upgrade_ancient": "1gb",
|
|
|
|
"size_to_upgrade_ancient_in_bytes": "1000000000"
|
2015-05-24 18:22:06 -04:00
|
|
|
}
|
|
|
|
}
|
2014-10-07 11:09:50 -04:00
|
|
|
}
|
|
|
|
--------------------------------------------------
|
2015-05-24 18:22:06 -04:00
|
|
|
|
|
|
|
The level of details in the upgrade status command can be controlled by
|
|
|
|
setting `level` parameter to `cluster`, `index` (default) or `shard` levels.
|
|
|
|
For example, you can run the upgrade status command with `level=shard` to
|
2015-09-17 16:36:25 -04:00
|
|
|
get detailed upgrade information of each individual shard.
|