class_docstr: A component that routes documents to different connections based on the content of their fields.
class_docstr_tok: ["A","component","that","routes","documents","to","different","connections","based","on","the","content","of","their","fields","."]
docstr: Run the MetadataRouter. This method routes the documents to different edges based on their fields content and
  the rules specified during initialization. If a document does not match any of the rules, it is routed to
  a connection named "unmatched".
  
  :param documents: A list of documents to route to different edges.
docstr_tok: ["Run","the","MetadataRouter",".","This","method","routes","the","documents","to","different","edges","based","on","their","fields","content","and","the","rules","specified","during","initialization",".","If","a","document","does","not","match","any","of","the","rules",",","it","is","routed","to","a","connection","named","``","unmatched","''",".",":","param","documents",":","A","list","of","documents","to","route","to","different","edges","."]
code: def run(self, documents: List[Document]):
      """
      Run the MetadataRouter. This method routes the documents to different edges based on their fields content and
      the rules specified during initialization. If a document does not match any of the rules, it is routed to
      a connection named "unmatched".
  
      :param documents: A list of documents to route to different edges.
      """
      unmatched_documents = []
      output: Dict[str, List[Document]] = {
          edge: [] for edge in self.rules
      }
  
      for document in documents:
          cur_document_matched = False
          for edge, rule in self.rules.items():
              if "operator" not in rule:
                  # Must be a legacy filter, convert it
                  rule = convert(rule)
              if document_matches_filter(rule, document):
                  output[edge].append(document)
                  cur_document_matched = True
  
          if not cur_document_matched:
              unmatched_documents.append(document)
  
      output["unmatched"] = unmatched_documents
      return output
  
imports: from typing import Dict, List
  from haystack import component, Document
  from haystack.utils.filters import document_matches_filter, convert
label_desc: Use image node_id 2 for calling the MetadataRouter obj's underlying member method code with example usage: obj.run(documents) and returns: output