<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def put_settings(self, app=None, index=None, settings=None, es=None):
 """Modify index settings. Index must exist already. """

        if not index:
            index = self.index

        if not app:
            app = self.app

        if not es:
            es = self.es

        if not settings:
            return

        for alias, old_settings in self.es.indices.get_settings(index=index).items():
            try:
                if test_settings_contain(old_settings['settings']['index'], settings['settings']):
                    return
            except KeyError:
                pass

        es.indices.close(index=index)
        es.indices.put_settings(index=index, body=settings)
        es.indices.open(index=index)