2013-08-28 19:24:34 -04:00
|
|
|
|
[[indices-update-settings]]
|
2019-08-27 12:49:18 -04:00
|
|
|
|
=== Update index settings API
|
|
|
|
|
++++
|
|
|
|
|
<titleabbrev>Update index settings</titleabbrev>
|
|
|
|
|
++++
|
2013-08-28 19:24:34 -04:00
|
|
|
|
|
2020-07-02 09:26:57 -04:00
|
|
|
|
Changes a <<index-modules-settings,dynamic index setting>> in real time.
|
|
|
|
|
|
|
|
|
|
For data streams, index setting changes are applied to all backing indices by
|
|
|
|
|
default.
|
2013-08-28 19:24:34 -04:00
|
|
|
|
|
2019-09-06 11:31:13 -04:00
|
|
|
|
[source,console]
|
2013-08-28 19:24:34 -04:00
|
|
|
|
--------------------------------------------------
|
2020-07-31 09:51:47 -04:00
|
|
|
|
PUT /my-index-000001/_settings
|
2013-08-28 19:24:34 -04:00
|
|
|
|
{
|
2020-07-21 15:49:58 -04:00
|
|
|
|
"index" : {
|
|
|
|
|
"number_of_replicas" : 2
|
|
|
|
|
}
|
2014-11-17 23:43:53 -05:00
|
|
|
|
}
|
2013-08-28 19:24:34 -04:00
|
|
|
|
--------------------------------------------------
|
2020-07-31 09:51:47 -04:00
|
|
|
|
// TEST[setup:my_index]
|
2013-08-28 19:24:34 -04:00
|
|
|
|
|
2019-08-27 12:49:18 -04:00
|
|
|
|
|
|
|
|
|
[[update-index-settings-api-request]]
|
|
|
|
|
==== {api-request-title}
|
|
|
|
|
|
2020-07-02 09:26:57 -04:00
|
|
|
|
`PUT /<target>/_settings`
|
2019-08-27 12:49:18 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
[[update-index-settings-api-path-params]]
|
|
|
|
|
==== {api-path-parms-title}
|
|
|
|
|
|
2020-07-02 09:26:57 -04:00
|
|
|
|
`<target>`::
|
|
|
|
|
(Optional, string)
|
|
|
|
|
Comma-separated list of data streams, indices, and index aliases used to limit
|
|
|
|
|
the request. Wildcard expressions (`*`) are supported.
|
2019-08-27 12:49:18 -04:00
|
|
|
|
+
|
2020-07-02 09:26:57 -04:00
|
|
|
|
To target all data streams and indices in a cluster, omit this parameter or use
|
|
|
|
|
`_all` or `*`.
|
2019-08-27 12:49:18 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
[[update-index-settings-api-query-params]]
|
|
|
|
|
==== {api-query-parms-title}
|
|
|
|
|
|
2020-06-01 19:42:53 -04:00
|
|
|
|
include::{es-repo-dir}/rest-api/common-parms.asciidoc[tag=allow-no-indices]
|
2020-02-24 05:57:32 -05:00
|
|
|
|
+
|
|
|
|
|
Defaults to `false`.
|
2019-08-27 12:49:18 -04:00
|
|
|
|
|
2020-06-01 19:42:53 -04:00
|
|
|
|
include::{es-repo-dir}/rest-api/common-parms.asciidoc[tag=expand-wildcards]
|
2019-08-27 12:49:18 -04:00
|
|
|
|
+
|
|
|
|
|
Defaults to `open`.
|
|
|
|
|
|
2020-06-01 19:42:53 -04:00
|
|
|
|
include::{es-repo-dir}/rest-api/common-parms.asciidoc[tag=flat-settings]
|
2019-08-27 12:49:18 -04:00
|
|
|
|
|
2020-06-01 19:42:53 -04:00
|
|
|
|
include::{es-repo-dir}/rest-api/common-parms.asciidoc[tag=index-ignore-unavailable]
|
2019-08-27 12:49:18 -04:00
|
|
|
|
|
|
|
|
|
`preserve_existing`::
|
|
|
|
|
(Optional, boolean) If `true`, existing index settings remain unchanged.
|
|
|
|
|
Defaults to `false`.
|
|
|
|
|
|
2020-06-01 19:42:53 -04:00
|
|
|
|
include::{es-repo-dir}/rest-api/common-parms.asciidoc[tag=timeoutparms]
|
2019-08-27 12:49:18 -04:00
|
|
|
|
|
|
|
|
|
|
2019-09-13 09:45:32 -04:00
|
|
|
|
[[update-index-settings-api-request-body]]
|
|
|
|
|
==== {api-request-body-title}
|
2019-08-27 12:49:18 -04:00
|
|
|
|
|
|
|
|
|
`settings`::
|
|
|
|
|
(Optional, <<index-modules-settings,index setting object>>) Configuration
|
|
|
|
|
options for the index. See <<index-modules-settings>>.
|
|
|
|
|
|
2019-09-13 09:45:32 -04:00
|
|
|
|
[[update-index-settings-api-example]]
|
2019-08-27 12:49:18 -04:00
|
|
|
|
==== {api-examples-title}
|
|
|
|
|
|
|
|
|
|
[[reset-index-setting]]
|
|
|
|
|
===== Reset an index setting
|
|
|
|
|
To revert a setting to the default value, use `null`. For example:
|
2018-03-19 23:04:58 -04:00
|
|
|
|
|
2019-09-06 11:31:13 -04:00
|
|
|
|
[source,console]
|
2018-03-19 23:04:58 -04:00
|
|
|
|
--------------------------------------------------
|
2020-07-31 09:51:47 -04:00
|
|
|
|
PUT /my-index-000001/_settings
|
2018-03-19 23:04:58 -04:00
|
|
|
|
{
|
2020-07-21 15:49:58 -04:00
|
|
|
|
"index" : {
|
|
|
|
|
"refresh_interval" : null
|
|
|
|
|
}
|
2018-03-19 23:04:58 -04:00
|
|
|
|
}
|
|
|
|
|
--------------------------------------------------
|
2020-07-31 09:51:47 -04:00
|
|
|
|
// TEST[setup:my_index]
|
2018-03-19 23:04:58 -04:00
|
|
|
|
|
2015-06-22 17:49:45 -04:00
|
|
|
|
The list of per-index settings which can be updated dynamically on live
|
|
|
|
|
indices can be found in <<index-modules>>.
|
2017-04-07 10:25:51 -04:00
|
|
|
|
To preserve existing settings from being updated, the `preserve_existing`
|
|
|
|
|
request parameter can be set to `true`.
|
2013-08-28 19:24:34 -04:00
|
|
|
|
|
2013-09-25 12:17:40 -04:00
|
|
|
|
[[bulk]]
|
2019-08-27 12:49:18 -04:00
|
|
|
|
===== Bulk indexing usage
|
2013-08-28 19:24:34 -04:00
|
|
|
|
|
|
|
|
|
For example, the update settings API can be used to dynamically change
|
|
|
|
|
the index from being more performant for bulk indexing, and then move it
|
|
|
|
|
to more real time indexing state. Before the bulk indexing is started,
|
|
|
|
|
use:
|
|
|
|
|
|
2019-09-06 11:31:13 -04:00
|
|
|
|
[source,console]
|
2013-08-28 19:24:34 -04:00
|
|
|
|
--------------------------------------------------
|
2020-07-31 09:51:47 -04:00
|
|
|
|
PUT /my-index-000001/_settings
|
2017-02-10 17:57:43 -05:00
|
|
|
|
{
|
2020-07-21 15:49:58 -04:00
|
|
|
|
"index" : {
|
|
|
|
|
"refresh_interval" : "-1"
|
|
|
|
|
}
|
2017-02-10 17:57:43 -05:00
|
|
|
|
}
|
2013-08-28 19:24:34 -04:00
|
|
|
|
--------------------------------------------------
|
2020-07-31 09:51:47 -04:00
|
|
|
|
// TEST[setup:my_index]
|
2013-08-28 19:24:34 -04:00
|
|
|
|
|
|
|
|
|
(Another optimization option is to start the index without any replicas,
|
|
|
|
|
and only later adding them, but that really depends on the use case).
|
|
|
|
|
|
|
|
|
|
Then, once bulk indexing is done, the settings can be updated (back to
|
|
|
|
|
the defaults for example):
|
|
|
|
|
|
2019-09-06 11:31:13 -04:00
|
|
|
|
[source,console]
|
2013-08-28 19:24:34 -04:00
|
|
|
|
--------------------------------------------------
|
2020-07-31 09:51:47 -04:00
|
|
|
|
PUT /my-index-000001/_settings
|
2017-02-10 17:57:43 -05:00
|
|
|
|
{
|
2020-07-21 15:49:58 -04:00
|
|
|
|
"index" : {
|
|
|
|
|
"refresh_interval" : "1s"
|
|
|
|
|
}
|
2017-02-10 17:57:43 -05:00
|
|
|
|
}
|
2013-08-28 19:24:34 -04:00
|
|
|
|
--------------------------------------------------
|
2017-02-10 17:57:43 -05:00
|
|
|
|
// TEST[continued]
|
2013-08-28 19:24:34 -04:00
|
|
|
|
|
2015-09-17 16:36:25 -04:00
|
|
|
|
And, a force merge should be called:
|
2013-08-28 19:24:34 -04:00
|
|
|
|
|
2019-09-06 11:31:13 -04:00
|
|
|
|
[source,console]
|
2013-08-28 19:24:34 -04:00
|
|
|
|
--------------------------------------------------
|
2020-07-31 09:51:47 -04:00
|
|
|
|
POST /my-index-000001/_forcemerge?max_num_segments=5
|
2013-08-28 19:24:34 -04:00
|
|
|
|
--------------------------------------------------
|
2017-02-10 17:57:43 -05:00
|
|
|
|
// TEST[continued]
|
2013-08-28 19:24:34 -04:00
|
|
|
|
|
2013-09-30 17:32:00 -04:00
|
|
|
|
[[update-settings-analysis]]
|
2019-08-27 12:49:18 -04:00
|
|
|
|
===== Update index analysis
|
2013-08-28 19:24:34 -04:00
|
|
|
|
|
2019-08-27 12:49:18 -04:00
|
|
|
|
You can only define new analyzers on closed indices.
|
2013-08-28 19:24:34 -04:00
|
|
|
|
|
2019-08-27 12:49:18 -04:00
|
|
|
|
To add an analyzer,
|
|
|
|
|
you must close the index,
|
|
|
|
|
define the analyzer,
|
|
|
|
|
and reopen the index.
|
2020-07-02 09:26:57 -04:00
|
|
|
|
|
|
|
|
|
[NOTE]
|
|
|
|
|
====
|
|
|
|
|
You cannot close the write index of a data stream.
|
|
|
|
|
|
|
|
|
|
To update the analyzer for a data stream's write index and future backing
|
|
|
|
|
indices, update the analyzer in the <<create-a-data-stream-template,index
|
|
|
|
|
template used by the stream>>. Then <<manually-roll-over-a-data-stream,roll over
|
|
|
|
|
the data stream>> to apply the new analyzer to the stream’s write index and
|
|
|
|
|
future backing indices. This affects searches and any new data added to the
|
|
|
|
|
stream after the rollover. However, it does not affect the data stream's backing
|
|
|
|
|
indices or their existing data.
|
|
|
|
|
|
|
|
|
|
To change the analyzer for existing backing indices, you must create a
|
|
|
|
|
new data stream and reindex your data into it. See
|
|
|
|
|
<<data-streams-use-reindex-to-change-mappings-settings>>.
|
|
|
|
|
====
|
|
|
|
|
|
2019-08-27 12:49:18 -04:00
|
|
|
|
For example,
|
2020-07-31 09:51:47 -04:00
|
|
|
|
the following commands add the `content` analyzer to the `my-index-000001` index:
|
2013-08-28 19:24:34 -04:00
|
|
|
|
|
2019-09-06 11:31:13 -04:00
|
|
|
|
[source,console]
|
2013-08-28 19:24:34 -04:00
|
|
|
|
--------------------------------------------------
|
2020-07-31 09:51:47 -04:00
|
|
|
|
POST /my-index-000001/_close
|
2013-08-28 19:24:34 -04:00
|
|
|
|
|
2020-07-31 09:51:47 -04:00
|
|
|
|
PUT /my-index-000001/_settings
|
2017-02-10 17:57:43 -05:00
|
|
|
|
{
|
2013-08-28 19:24:34 -04:00
|
|
|
|
"analysis" : {
|
|
|
|
|
"analyzer":{
|
|
|
|
|
"content":{
|
|
|
|
|
"type":"custom",
|
|
|
|
|
"tokenizer":"whitespace"
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2017-02-10 17:57:43 -05:00
|
|
|
|
}
|
2013-08-28 19:24:34 -04:00
|
|
|
|
|
2020-07-31 09:51:47 -04:00
|
|
|
|
POST /my-index-000001/_open
|
2013-08-28 19:24:34 -04:00
|
|
|
|
--------------------------------------------------
|
2020-07-31 09:51:47 -04:00
|
|
|
|
// TEST[setup:my_index]
|