Add refresh setting

* close index, then update, reopen, refresh and optimize