SDK
SDK Javascript v6.x
1

You are currently looking at the documentation of a previous version of Kuzzle. We strongly recommend that you use the latest version. You can also use the version selector in the top menu.

setAutoRefresh #

The setAutoRefresh action allows to set the autorefresh flag for a index.

Each index has an autorefresh flag. When set to true, each write request trigger a refresh action on Elasticsearch. Without a refresh after a write request, the documents may not be immediately visible in search.

A refresh operation comes with performance costs. While forcing the autoRefresh can be convenient on a development or test environment, we recommend that you avoid using it in production or at least carefully monitor its implications before using it.


Copied to clipboard!
setAutoRefresh(index, autoRefresh, [options]);

Arguments Type Description
index
string
Index name
autoRefresh
boolean
AutoRefresh value
options
number
Query options

options #

Additional query options

Property Type
(default)
Description
queuable
boolean

(true)
If true, queues the request during downtime, until connected to Kuzzle again

Resolves #

Resolves to a boolean representing the new value of the autorefresh flag.

Usage #

Copied to clipboard!
try {
  const autoRefresh = await kuzzle.index.setAutoRefresh('nyc-open-data', true);
  if (autoRefresh === true) {
    console.log(`Autorefresh flag is set to true`);
  }
} catch (error) {
  console.error(error.message);
}