docs: def filter_indices(self, options, verbosity, *args, **kwargs):
          """Filter indices and execute an action for each index."""
          index_name_map = {
              index.__class__.__name__: index
              for index in index_builder.indexes
          }
  
          # Process includes.
          if options['index']:
              indices = set(options['index'])
          else:
              indices = set(index_name_map.keys())
  
          # Process excludes.
          for index_name in options['exclude']:
              if index_name not in index_name_map:
                  self.invalid_index(index_name)
                  return
  
              indices.discard(index_name)
  
          # Execute action for each remaining index.
          for index_name in indices:
              try:
                  index = index_name_map[index_name]
              except KeyError:
                  self.invalid_index(index_name)
                  return
  
              if verbosity > 0:
                  self.stdout.write("Processing index '{}'...".format(index_name))
              self.handle_index(index, *args, **kwargs)