docs: def optimize(host=None, core_name=None):
      '''
      Search queries fast, but it is a very expensive operation. The ideal
      process is to run this with a master/slave configuration.  Then you
      can optimize the master, and push the optimized index to the slaves.
      If you are running a single solr instance, or if you are going to run
      this on a slave be aware than search performance will be horrible
      while this command is being run. Additionally it can take a LONG time
      to run and your HTTP request may timeout. If that happens adjust your
      timeout settings.
  
      host : str (None)
          The solr host to query. __opts__['host'] is default.
      core_name : str (None)
          The name of the solr core if using cores. Leave this blank if you are
          not using cores or if you want to check all cores.
  
      Return : dict<str,obj>::
  
          {'success':boolean, 'data':dict, 'errors':list, 'warnings':list}
  
      CLI Example:
  
      .. code-block:: bash
  
          salt '*' solr.optimize music
      '''
      ret = _get_return_dict()
  
      if _get_none_or_value(core_name) is None and _check_for_cores():
          success = True
          for name in __salt__['config.option']('solr.cores'):
              url = _format_url('update', host=host, core_name=name,
                                extra=["optimize=true"])
              resp = _http_request(url)
              if resp['success']:
                  data = {name: {'data': resp['data']}}
                  ret = _update_return_dict(ret, success, data,
                                             resp['errors'], resp['warnings'])
              else:
                  success = False
                  data = {name: {'data': resp['data']}}
                  ret = _update_return_dict(ret, success, data,
                                             resp['errors'], resp['warnings'])
          return ret
      else:
          url = _format_url('update', host=host, core_name=core_name,
                            extra=["optimize=true"])
          return _http_request(url)