docs: def optimize(self, indices=None,
                   wait_for_merge=False,
                   max_num_segments=None,
                   only_expunge_deletes=False,
                   refresh=True,
                   flush=True):
          """
          Optimize one or more indices.
          (See :ref:`es-guide-reference-api-admin-indices-optimize`)
  
  
          :keyword indices: the list of indices to optimise.  If not supplied, all
                            default_indices are optimised.
  
          :keyword wait_for_merge: If True, the operation will not return until the merge has been completed.
                                   Defaults to False.
  
          :keyword max_num_segments: The number of segments to optimize to. To fully optimize the index, set it to 1.
                                     Defaults to half the number configured by the merge policy (which in turn defaults
                                     to 10).
  
  
          :keyword only_expunge_deletes: Should the optimize process only expunge segments with deletes in it.
                                         In Lucene, a document is not deleted from a segment, just marked as deleted.
                                         During a merge process of segments, a new segment is created that does have
                                         those deletes.
                                         This flag allow to only merge segments that have deletes. Defaults to false.
  
          :keyword refresh: Should a refresh be performed after the optimize. Defaults to true.
  
          :keyword flush: Should a flush be performed after the optimize. Defaults to true.
  
          """
          path = self.conn._make_path(indices, (), '_optimize')
          params = dict(
              wait_for_merge=wait_for_merge,
              only_expunge_deletes=only_expunge_deletes,
              refresh=refresh,
              flush=flush,
              )
          for k, v in params.items():
              params[k] = v and "true" or "false"
          if max_num_segments is not None:
              params['max_num_segments'] = max_num_segments
          return self.conn._send_request('POST', path, params=params)