How it works...

To reduce writing, Elasticsearch tries not to put overheads in I/O operations and it caches some data in memory until refreshing occurs, enabling the execution of a multi-documents single write to improve performance.

To clean up memory and force this data on disk, the flush operation is required.

In the flush call, it is possible to give an extra request parameter, refresh, which is also used to force the index to refresh.

Flushing too often affects index performance. Use it wisely!