Search code examples
scalaelasticsearchelastic4s

How to change settings of an index after creation in elastic4s?


I'd need to disable index refreshing for the course of a batch indexing (of gigabytes) and set it back again after it's done. But from the source code of elastic4s I can't find a way to do it other than at index creation time... Is it possible? Or is there a workaround for this?

In java client :

client
  .admin
  .indices()
  .prepareUpdateSettings()
  .setSettings(settings)
  .setIndices(indexName)
  .execute()
  .actionGet()

Natively :

curl -XPUT 'localhost:9200/my_index/_settings' -d '
{
    "index" : {
        "refresh_interval" : -1
    }
}
'

Solution

  • This is how you do it in elastic4s (for example setting the refresh interval property).

    client.execute {
      update settings "myindex" set Map("index.refresh_interval" -> "10s")
    }
    

    Note: Not all settings can be changed at runtime or after the index is created.

    Note 2: I have added this API in response to your question, and is only available in version 1.5.1 onwards.

    Note 3: I could back port it to 1.4.x or 1.3.x if required by anyone.