2013-08-28 19:24:34 -04:00
|
|
|
[[indices-update-settings]]
|
2019-07-19 14:35:36 -04:00
|
|
|
=== Update Indices Settings
|
2013-08-28 19:24:34 -04:00
|
|
|
|
|
|
|
Change specific index level settings in real time.
|
|
|
|
|
|
|
|
The REST endpoint is `/_settings` (to update all indices) or
|
2017-04-07 10:25:51 -04:00
|
|
|
`{index}/_settings` to update one (or more) indices settings.
|
|
|
|
The body of the request includes the updated settings, for example:
|
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
|
|
|
|
2018-03-19 23:04:58 -04:00
|
|
|
To reset a setting back to the default value, use `null`. For example:
|
|
|
|
|
|
|
|
[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
|
|
|
|
|
|
|
[float]
|
2013-09-25 12:17:40 -04:00
|
|
|
[[bulk]]
|
2019-07-19 14:35:36 -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
|
|
|
|
|
|
|
[float]
|
2013-09-30 17:32:00 -04:00
|
|
|
[[update-settings-analysis]]
|
2019-07-19 14:35:36 -04:00
|
|
|
==== Updating Index Analysis
|
2013-08-28 19:24:34 -04:00
|
|
|
|
|
|
|
It is also possible to define new <<analysis,analyzers>> for the index.
|
|
|
|
But it is required to <<indices-open-close,close>> the index
|
|
|
|
first and <<indices-open-close,open>> it after the changes are made.
|
|
|
|
|
|
|
|
For example if `content` analyzer hasn't been defined on `myindex` yet
|
|
|
|
you can use the following commands to add it:
|
|
|
|
|
|
|
|
[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]
|