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
|
|
|
|
2019-08-27 12:49:18 -04:00
|
|
|
Changes an <<index-modules-settings,index setting>> in real time.
|
2013-08-28 19:24:34 -04:00
|
|
|
|
|
|
|
[source,js]
|
|
|
|
--------------------------------------------------
|
2017-02-10 17:57:43 -05:00
|
|
|
PUT /twitter/_settings
|
2013-08-28 19:24:34 -04:00
|
|
|
{
|
|
|
|
"index" : {
|
2017-02-10 17:57:43 -05:00
|
|
|
"number_of_replicas" : 2
|
2015-04-26 12:49:15 -04:00
|
|
|
}
|
2014-11-17 23:43:53 -05:00
|
|
|
}
|
2013-08-28 19:24:34 -04:00
|
|
|
--------------------------------------------------
|
2017-02-10 17:57:43 -05:00
|
|
|
// CONSOLE
|
|
|
|
// TEST[setup:twitter]
|
2013-08-28 19:24:34 -04:00
|
|
|
|
2019-08-27 12:49:18 -04:00
|
|
|
|
|
|
|
[[update-index-settings-api-request]]
|
|
|
|
==== {api-request-title}
|
|
|
|
|
|
|
|
`PUT /<index>/_settings`
|
|
|
|
|
|
|
|
|
|
|
|
[[update-index-settings-api-path-params]]
|
|
|
|
==== {api-path-parms-title}
|
|
|
|
|
|
|
|
include::{docdir}/rest-api/common-parms.asciidoc[tag=index]
|
|
|
|
+
|
|
|
|
To update a setting for all indices,
|
|
|
|
use `_all` or exclude this parameter.
|
|
|
|
|
|
|
|
|
|
|
|
[[update-index-settings-api-query-params]]
|
|
|
|
==== {api-query-parms-title}
|
|
|
|
|
|
|
|
include::{docdir}/rest-api/common-parms.asciidoc[tag=allow-no-indices]
|
|
|
|
|
|
|
|
include::{docdir}/rest-api/common-parms.asciidoc[tag=expand-wildcards]
|
|
|
|
+
|
|
|
|
Defaults to `open`.
|
|
|
|
|
|
|
|
include::{docdir}/rest-api/common-parms.asciidoc[tag=flat-settings]
|
|
|
|
|
|
|
|
include::{docdir}/rest-api/common-parms.asciidoc[tag=index-ignore-unavailable]
|
|
|
|
|
|
|
|
`preserve_existing`::
|
|
|
|
(Optional, boolean) If `true`, existing index settings remain unchanged.
|
|
|
|
Defaults to `false`.
|
|
|
|
|
|
|
|
include::{docdir}/rest-api/common-parms.asciidoc[tag=timeoutparms]
|
|
|
|
|
|
|
|
|
|
|
|
[[sample-api-query-params]]
|
|
|
|
==== {api-query-parms-title}
|
|
|
|
|
|
|
|
`settings`::
|
|
|
|
(Optional, <<index-modules-settings,index setting object>>) Configuration
|
|
|
|
options for the index. See <<index-modules-settings>>.
|
|
|
|
|
|
|
|
[[sample-api-example]]
|
|
|
|
==== {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
|
|
|
|
|
|
|
[source,js]
|
|
|
|
--------------------------------------------------
|
|
|
|
PUT /twitter/_settings
|
|
|
|
{
|
|
|
|
"index" : {
|
|
|
|
"refresh_interval" : null
|
|
|
|
}
|
|
|
|
}
|
|
|
|
--------------------------------------------------
|
|
|
|
// CONSOLE
|
|
|
|
// TEST[setup:twitter]
|
|
|
|
|
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:
|
|
|
|
|
|
|
|
[source,js]
|
|
|
|
--------------------------------------------------
|
2017-02-10 17:57:43 -05:00
|
|
|
PUT /twitter/_settings
|
|
|
|
{
|
2013-08-28 19:24:34 -04:00
|
|
|
"index" : {
|
|
|
|
"refresh_interval" : "-1"
|
2017-02-10 17:57:43 -05:00
|
|
|
}
|
|
|
|
}
|
2013-08-28 19:24:34 -04:00
|
|
|
--------------------------------------------------
|
2017-02-10 17:57:43 -05:00
|
|
|
// CONSOLE
|
|
|
|
// TEST[setup:twitter]
|
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):
|
|
|
|
|
|
|
|
[source,js]
|
|
|
|
--------------------------------------------------
|
2017-02-10 17:57:43 -05:00
|
|
|
PUT /twitter/_settings
|
|
|
|
{
|
2013-08-28 19:24:34 -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
|
|
|
// CONSOLE
|
|
|
|
// 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
|
|
|
|
|
|
|
[source,js]
|
|
|
|
--------------------------------------------------
|
2017-02-10 17:57:43 -05:00
|
|
|
POST /twitter/_forcemerge?max_num_segments=5
|
2013-08-28 19:24:34 -04:00
|
|
|
--------------------------------------------------
|
2017-02-10 17:57:43 -05:00
|
|
|
// CONSOLE
|
|
|
|
// 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.
|
|
|
|
For example,
|
|
|
|
the following commands add the `content` analyzer to `myindex`:
|
2013-08-28 19:24:34 -04:00
|
|
|
|
|
|
|
[source,js]
|
|
|
|
--------------------------------------------------
|
2017-02-10 17:57:43 -05:00
|
|
|
POST /twitter/_close
|
2013-08-28 19:24:34 -04:00
|
|
|
|
2017-02-10 17:57:43 -05:00
|
|
|
PUT /twitter/_settings
|
|
|
|
{
|
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
|
|
|
|
2017-02-10 17:57:43 -05:00
|
|
|
POST /twitter/_open
|
2013-08-28 19:24:34 -04:00
|
|
|
--------------------------------------------------
|
2017-02-10 17:57:43 -05:00
|
|
|
// CONSOLE
|
|
|
|
// TEST[setup:twitter]
|