2013-08-28 19:24:34 -04:00
|
|
|
[[indices-update-settings]]
|
|
|
|
== Update Indices Settings
|
|
|
|
|
|
|
|
Change specific index level settings in real time.
|
|
|
|
|
|
|
|
The REST endpoint is `/_settings` (to update all indices) or
|
|
|
|
`{index}/_settings` to update one (or more) indices settings. The body
|
|
|
|
of the request includes the updated settings, for example:
|
|
|
|
|
|
|
|
[source,js]
|
|
|
|
--------------------------------------------------
|
|
|
|
{
|
|
|
|
"index" : {
|
|
|
|
"number_of_replicas" : 4
|
2015-04-26 12:49:15 -04:00
|
|
|
}
|
2014-11-17 23:43:53 -05:00
|
|
|
}
|
2013-08-28 19:24:34 -04:00
|
|
|
--------------------------------------------------
|
|
|
|
|
|
|
|
The above will change the number of replicas to 4 from the current
|
|
|
|
number of replicas. Here is a curl example:
|
|
|
|
|
|
|
|
[source,js]
|
|
|
|
--------------------------------------------------
|
|
|
|
curl -XPUT 'localhost:9200/my_index/_settings' -d '
|
|
|
|
{
|
|
|
|
"index" : {
|
|
|
|
"number_of_replicas" : 4
|
2015-04-26 12:49:15 -04:00
|
|
|
}
|
2014-11-17 23:43:53 -05:00
|
|
|
}'
|
2013-08-28 19:24:34 -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>>.
|
2013-08-28 19:24:34 -04:00
|
|
|
|
|
|
|
[float]
|
2013-09-25 12:17:40 -04:00
|
|
|
[[bulk]]
|
2013-08-28 19:24:34 -04:00
|
|
|
=== Bulk Indexing Usage
|
|
|
|
|
|
|
|
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]
|
|
|
|
--------------------------------------------------
|
|
|
|
curl -XPUT localhost:9200/test/_settings -d '{
|
|
|
|
"index" : {
|
|
|
|
"refresh_interval" : "-1"
|
|
|
|
} }'
|
|
|
|
--------------------------------------------------
|
|
|
|
|
|
|
|
(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]
|
|
|
|
--------------------------------------------------
|
|
|
|
curl -XPUT localhost:9200/test/_settings -d '{
|
|
|
|
"index" : {
|
|
|
|
"refresh_interval" : "1s"
|
|
|
|
} }'
|
|
|
|
--------------------------------------------------
|
|
|
|
|
|
|
|
And, an optimize should be called:
|
|
|
|
|
|
|
|
[source,js]
|
|
|
|
--------------------------------------------------
|
|
|
|
curl -XPOST 'http://localhost:9200/test/_optimize?max_num_segments=5'
|
|
|
|
--------------------------------------------------
|
|
|
|
|
|
|
|
[float]
|
2013-09-30 17:32:00 -04:00
|
|
|
[[update-settings-analysis]]
|
2013-08-28 19:24:34 -04:00
|
|
|
=== Updating Index Analysis
|
|
|
|
|
|
|
|
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]
|
|
|
|
--------------------------------------------------
|
|
|
|
curl -XPOST 'localhost:9200/myindex/_close'
|
|
|
|
|
|
|
|
curl -XPUT 'localhost:9200/myindex/_settings' -d '{
|
|
|
|
"analysis" : {
|
|
|
|
"analyzer":{
|
|
|
|
"content":{
|
|
|
|
"type":"custom",
|
|
|
|
"tokenizer":"whitespace"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}'
|
|
|
|
|
|
|
|
curl -XPOST 'localhost:9200/myindex/_open'
|
|
|
|
--------------------------------------------------
|