setAutoRefresh

The setAutoRefresh action allows to set the autorefresh flag for the 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 some 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.

Signature

Copied to clipboard!
void setAutoRefresh(const std::string& index, bool auto_refresh);

void setAutoRefresh(
    const std::string& index,
    bool auto_refresh,
    const kuzzleio::query_options& options);

Arguments

Arguments Type Description
index
const std::string&
Index name
autoRefresh
bool
Autorefresh flag value
options
kuzzleio::query_options*
Query options

options

Additional query options

Option Type
(default)
Description
queuable
bool

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

Exceptions

Throws a kuzzleio::KuzzleException if there is an error. See how to handle error.

Usage

Copied to clipboard!
try {
  kuzzle->index->setAutoRefresh("nyc-open-data", true);

  std::cout << "Autorefresh is now enabled on index" << std::endl;
} catch (kuzzleio::KuzzleException &e) {
  std::cerr << e.what() << std::endl;
}